Favicon by RealFaviconGenerator - Version 1.0.2

Version Description

  • Callback URL was too long for some servers. It has been shorten.
Download this release

Release Info

Developer phbernard
Plugin Icon 128x128 Favicon by RealFaviconGenerator
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.2

README.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: phbernard
3
  Tags: favicon, apple-touch-icon, realfavicongenerator
4
  Requires at least: 3.5
5
  Tested up to: 3.9
6
- Stable tag: 1.0.1
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -61,6 +61,10 @@ This screen presents you a preview of the favicon you various platforms, so you
61
 
62
  == Changelog ==
63
 
 
 
 
 
64
  = 1.0.1 =
65
 
66
  - Favicon admin settings are now in the Appearance menu.
3
  Tags: favicon, apple-touch-icon, realfavicongenerator
4
  Requires at least: 3.5
5
  Tested up to: 3.9
6
+ Stable tag: 1.0.2
7
  License: GPLv2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
61
 
62
  == Changelog ==
63
 
64
+ = 1.0.2 =
65
+
66
+ - Callback URL was too long for some servers. It has been shorten.
67
+
68
  = 1.0.1 =
69
 
70
  - Favicon admin settings are now in the Appearance menu.
admin/class-favicon-by-realfavicongenerator-admin.php CHANGED
@@ -65,20 +65,16 @@ class Favicon_By_RealFaviconGenerator_Admin extends Favicon_By_RealFaviconGenera
65
 
66
  $preview_url = $this->is_preview_available() ? $this->get_preview_url() : NULL;
67
 
68
- if ( isset( $_REQUEST['json_result'] ) ) {
69
  // New favicon to install:
70
  // Parameters will be processed with an Ajax call
71
 
72
- // Encode the parameters to avoid special characters issues in JS
73
- // (see settings.php).
74
- // Note that this is *not* related to the classic encod/decode that occurs
75
- // when doing classic Ajax invocation, this is another "extra" encoding.
76
- $new_favicon_params = urlencode( stripslashes_deep( $_REQUEST['json_result'] ) );
77
  $ajax_url = admin_url( 'admin-ajax.php', isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://' );
78
  }
79
  else {
80
  // No new favicon, simply display the settings page
81
- $new_favicon_params = NULL;
82
  }
83
 
84
  // External files
@@ -91,12 +87,28 @@ class Favicon_By_RealFaviconGenerator_Admin extends Favicon_By_RealFaviconGenera
91
  include_once( plugin_dir_path(__FILE__) . 'views/settings.php' );
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  public function install_new_favicon() {
95
  header("Content-type: application/json");
96
 
97
  try {
98
  // URL is explicitely decoded to compensate the extra encoding performed while generating the settings page
99
- $result = urldecode( stripslashes_deep( $_REQUEST['json_result'] ) );
 
 
100
 
101
  $response = new Favicon_By_RealFaviconGenerator_Api_Response( $result );
102
 
65
 
66
  $preview_url = $this->is_preview_available() ? $this->get_preview_url() : NULL;
67
 
68
+ if ( isset( $_REQUEST['json_result_url'] ) ) {
69
  // New favicon to install:
70
  // Parameters will be processed with an Ajax call
71
 
72
+ $new_favicon_params_url = $_REQUEST['json_result_url'];
 
 
 
 
73
  $ajax_url = admin_url( 'admin-ajax.php', isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://' );
74
  }
75
  else {
76
  // No new favicon, simply display the settings page
77
+ $new_favicon_params_url = NULL;
78
  }
79
 
80
  // External files
87
  include_once( plugin_dir_path(__FILE__) . 'views/settings.php' );
88
  }
89
 
90
+ private function download_result_json( $url ) {
91
+ $resp = wp_remote_get( $url );
92
+ if ( is_wp_error( $resp )) {
93
+ throw new InvalidArgumentException( "Cannot download JSON file at " . $url . ": " . $resp->get_error_message() );
94
+ }
95
+
96
+ $json = wp_remote_retrieve_body( $resp );
97
+ if ( empty( $json ) ) {
98
+ throw new InvalidArgumentException( "Empty JSON document at " . $url );
99
+ }
100
+
101
+ return $json;
102
+ }
103
+
104
  public function install_new_favicon() {
105
  header("Content-type: application/json");
106
 
107
  try {
108
  // URL is explicitely decoded to compensate the extra encoding performed while generating the settings page
109
+ $url = $_REQUEST['json_result_url'];
110
+
111
+ $result = $this->download_result_json( $url );
112
 
113
  $response = new Favicon_By_RealFaviconGenerator_Api_Response( $result );
114
 
admin/views/settings.php CHANGED
@@ -6,7 +6,7 @@
6
 
7
  <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
8
 
9
- <?php if ( $new_favicon_params ) { ?>
10
  <div id="install_in_progress_message" class="updated">
11
  <p><?php _e( 'Favicon installation in progress. Please wait...', FBRFG_PLUGIN_SLUG ) ?></p>
12
  </div>
@@ -39,9 +39,9 @@
39
  }
40
  } ?>
41
 
42
- <div id="favicon_form_container" <?php echo $new_favicon_params ? 'style="display:none"' : '' ?>>
43
  <h3><?php _e( 'Favicon generation', FBRFG_PLUGIN_SLUG ) ?></h3>
44
- <?php if ( $favicon_configured || $new_favicon_params ) { ?>
45
  <p><?php _e( 'You can replace the existing favicon.', FBRFG_PLUGIN_SLUG ) ?></p>
46
  <?php } ?>
47
  <form role="form" method="post" action="http://realfavicongenerator.net/api/favicon_generator" id="favicon_form">
@@ -117,14 +117,15 @@
117
 
118
  params.favicon_generation.callback.type = 'url';
119
  params.favicon_generation.callback.url = "<?php echo admin_url('themes.php?page=favicon-by-realfavicongenerator/admin/class-favicon-by-realfavicongenerator-admin.phpfavicon_settings_menu') ?>";
 
120
 
121
  return params;
122
  }
123
 
124
- <?php if ( $new_favicon_params ) { ?>
125
  var data = {
126
  action: '<?php echo Favicon_By_RealFaviconGenerator_Common::PLUGIN_PREFIX . '_install_new_favicon' ?>',
127
- json_result: '<?php echo $new_favicon_params ?>'
128
  };
129
  <?php } ?>
130
 
@@ -133,7 +134,7 @@
133
  jQuery('#json_params').val(JSON.stringify(computeJson()));
134
  });
135
 
136
- <?php if ( $new_favicon_params ) { ?>
137
  jQuery.get('<?php echo $ajax_url ?>', data, function(response) {
138
  if (response.status == 'success') {
139
  jQuery('#preview_image').attr('src', response.preview_url);
6
 
7
  <h2><?php echo esc_html( get_admin_page_title() ); ?></h2>
8
 
9
+ <?php if ( $new_favicon_params_url ) { ?>
10
  <div id="install_in_progress_message" class="updated">
11
  <p><?php _e( 'Favicon installation in progress. Please wait...', FBRFG_PLUGIN_SLUG ) ?></p>
12
  </div>
39
  }
40
  } ?>
41
 
42
+ <div id="favicon_form_container" <?php echo $new_favicon_params_url ? 'style="display:none"' : '' ?>>
43
  <h3><?php _e( 'Favicon generation', FBRFG_PLUGIN_SLUG ) ?></h3>
44
+ <?php if ( $favicon_configured || $new_favicon_params_url ) { ?>
45
  <p><?php _e( 'You can replace the existing favicon.', FBRFG_PLUGIN_SLUG ) ?></p>
46
  <?php } ?>
47
  <form role="form" method="post" action="http://realfavicongenerator.net/api/favicon_generator" id="favicon_form">
117
 
118
  params.favicon_generation.callback.type = 'url';
119
  params.favicon_generation.callback.url = "<?php echo admin_url('themes.php?page=favicon-by-realfavicongenerator/admin/class-favicon-by-realfavicongenerator-admin.phpfavicon_settings_menu') ?>";
120
+ params.favicon_generation.callback.short_url = 'true';
121
 
122
  return params;
123
  }
124
 
125
+ <?php if ( $new_favicon_params_url ) { ?>
126
  var data = {
127
  action: '<?php echo Favicon_By_RealFaviconGenerator_Common::PLUGIN_PREFIX . '_install_new_favicon' ?>',
128
+ json_result_url: '<?php echo $new_favicon_params_url ?>'
129
  };
130
  <?php } ?>
131
 
134
  jQuery('#json_params').val(JSON.stringify(computeJson()));
135
  });
136
 
137
+ <?php if ( $new_favicon_params_url ) { ?>
138
  jQuery.get('<?php echo $ajax_url ?>', data, function(response) {
139
  if (response.status == 'success') {
140
  jQuery('#preview_image').attr('src', response.preview_url);
assets/screenshot-1.png DELETED
Binary file
assets/screenshot-2.png DELETED
Binary file
assets/screenshot-3.png DELETED
Binary file
assets/screenshot-4.png DELETED
Binary file
favicon-by-realfavicongenerator.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Favicon by RealFaviconGenerator
13
  * Plugin URI: http://realfavicongenerator.net/extensions/wordpress
14
  * Description: Create and install your favicon for all platforms: PC/Mac of course, but also iPhone/iPad, Android devices, Windows 8 tablets, etc.
15
- * Version: 1.0.1
16
  * Author: Philippe Bernard
17
  * Author URI: http://realfavicongenerator.net/
18
  * License: GPLv2
12
  * Plugin Name: Favicon by RealFaviconGenerator
13
  * Plugin URI: http://realfavicongenerator.net/extensions/wordpress
14
  * Description: Create and install your favicon for all platforms: PC/Mac of course, but also iPhone/iPad, Android devices, Windows 8 tablets, etc.
15
+ * Version: 1.0.2
16
  * Author: Philippe Bernard
17
  * Author URI: http://realfavicongenerator.net/
18
  * License: GPLv2