WordPress Popular Posts - Version 5.2.2

Version Description

If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is required.

  • Fixes compatibility issue with plugins that minify HTML code.
  • Updates installation instructions.
  • Other minor improvements.

Release notes

Download this release

Release Info

Developer hcabrera
Plugin Icon 128x128 WordPress Popular Posts
Version 5.2.2
Comparing to
See all releases

Code changes from version 5.2.1 to 5.2.2

assets/js/{wpp-5.2.1.min.js → wpp.min.js} RENAMED
File without changes
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: hcabrera
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hcabrerab%40gmail%2ecom&lc=GB&item_name=WordPress%20Popular%20Posts%20Plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted
4
  Tags: popular, posts, widget, popularity, top
5
- Requires at least: 4.7
6
  Tested up to: 5.4.2
7
  Requires PHP: 5.4
8
- Stable tag: 5.2.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -61,9 +61,10 @@ Please make sure your site meets the [minimum requirements](https://github.com/c
61
 
62
  1. Go to Appearance > Widgets, drag and drop the **WordPress Popular Posts** widget to your sidebar. Once you're done configuring it, hit the Save button.
63
  2. If you have a caching plugin installed on your site, flush its cache now so WPP can start tracking your site.
64
- 3. If you have a security / firewall plugin installed on your site, make sure you [allow WPP access to the REST API](https://wordpress.org/support/topic/wpp-does-not-count-properly/#post-10411163) so it can start tracking your site.
65
- 4. Go to Appearance > Editor. Under "Templates", click on `header.php` and make sure that the `<?php wp_head(); ?>` tag is present (should be right before the closing `</head>` tag).
66
- 5. (Optional but highly recommended) Are you running a medium/high traffic site? If so, it might be a good idea to check [these suggestions](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance) to make sure your site's performance stays up to par.
 
67
 
68
  That's it!
69
 
@@ -89,6 +90,16 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
89
  4. Statistics panel.
90
 
91
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
92
  = 5.2.1 =
93
 
94
  **If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is required.**
@@ -97,7 +108,7 @@ The FAQ section has been moved [here](https://github.com/cabrerahector/wordpress
97
  - Makes sure non-ajaxified themed widgets are properly moved into the ShadowRoot.
98
  - Fixes declaration of the wpp_params variable.
99
 
100
- [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-5-2-is-here)
101
 
102
  = 5.2.0 =
103
 
2
  Contributors: hcabrera
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=hcabrerab%40gmail%2ecom&lc=GB&item_name=WordPress%20Popular%20Posts%20Plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG_global%2egif%3aNonHosted
4
  Tags: popular, posts, widget, popularity, top
5
+ Requires at least: 4.9
6
  Tested up to: 5.4.2
7
  Requires PHP: 5.4
8
+ Stable tag: 5.2.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
61
 
62
  1. Go to Appearance > Widgets, drag and drop the **WordPress Popular Posts** widget to your sidebar. Once you're done configuring it, hit the Save button.
63
  2. If you have a caching plugin installed on your site, flush its cache now so WPP can start tracking your site.
64
+ 3. If you have a plugin that minifies JavaScript (JS) installed on your site please read this FAQ: [Is WordPress Popular Posts compatible with plugins that minify/bundle JavaScript code?](https://github.com/cabrerahector/wordpress-popular-posts/wiki/5.-FAQ#is-wordpress-popular-posts-compatible-with-plugins-that-minifybundle-javascript-code)
65
+ 4. If you have a security / firewall plugin installed on your site, make sure you [allow WPP access to the REST API](https://wordpress.org/support/topic/wpp-does-not-count-properly/#post-10411163) so it can start tracking your site.
66
+ 5. Go to Appearance > Editor. Under "Templates", click on `header.php` and make sure that the `<?php wp_head(); ?>` tag is present (should be right before the closing `</head>` tag).
67
+ 6. (Optional but highly recommended) Are you running a medium/high traffic site? If so, it might be a good idea to check [these suggestions](https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance) to make sure your site's performance stays up to par.
68
 
69
  That's it!
70
 
90
  4. Statistics panel.
91
 
92
  == Changelog ==
93
+ = 5.2.2 =
94
+
95
+ **If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is required.**
96
+
97
+ - Fixes compatibility issue with plugins that minify HTML code.
98
+ - Updates installation instructions.
99
+ - Other minor improvements.
100
+
101
+ [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-5-2-is-here#hotfixes-and-minor-updates)
102
+
103
  = 5.2.1 =
104
 
105
  **If you're using a caching plugin, flushing its cache right after installing / upgrading to this version is required.**
108
  - Makes sure non-ajaxified themed widgets are properly moved into the ShadowRoot.
109
  - Fixes declaration of the wpp_params variable.
110
 
111
+ [Release notes](https://cabrerahector.com/wordpress/wordpress-popular-posts-5-2-is-here#hotfixes-and-minor-updates)
112
 
113
  = 5.2.0 =
114
 
src/Admin/admin-page.php CHANGED
@@ -516,7 +516,7 @@ if ( ! $wpp_rand = get_option("wpp_rand") ) {
516
  </td>
517
  </tr>
518
  <tr valign="top">
519
- <th scope="row"><label for="cache"><?php _e("Data Caching", 'wordpress-popular-posts'); ?>:</label> <small>[<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching" target="_blank" title="<?php _e('What is this?', 'wordpress-popular-posts'); ?>">?</a>]</small></th>
520
  <td>
521
  <select name="cache" id="cache">
522
  <option <?php if ( ! $this->config['tools']['cache']['active'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("Never cache", 'wordpress-popular-posts'); ?></option>
516
  </td>
517
  </tr>
518
  <tr valign="top">
519
+ <th scope="row"><label for="cache"><?php _e("Data Caching", 'wordpress-popular-posts'); ?>:</label> <small>[<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching-db-queries-results" target="_blank" title="<?php _e('What is this?', 'wordpress-popular-posts'); ?>">?</a>]</small></th>
520
  <td>
521
  <select name="cache" id="cache">
522
  <option <?php if ( ! $this->config['tools']['cache']['active'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("Never cache", 'wordpress-popular-posts'); ?></option>
src/Front/Front.php CHANGED
@@ -89,7 +89,28 @@ class Front {
89
  }
90
 
91
  // Enqueue WPP's library.
92
- wp_enqueue_script('wpp-js', plugin_dir_url(dirname(dirname(__FILE__))) . 'assets/js/wpp-5.2.1.min.js', [], WPP_VERSION, false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
  /**
@@ -109,31 +130,12 @@ class Front {
109
  function convert_inline_js_into_json($tag, $handle, $src)
110
  {
111
  if ( 'wpp-js' === $handle ) {
112
- $is_single = 0;
113
- $lang = ( function_exists('PLL') )
114
- ? $this->translate->get_current_language()
115
- : null;
116
-
117
- if (
118
- ( 0 == $this->config['tools']['log']['level'] && ! is_user_logged_in() )
119
- || ( 1 == $this->config['tools']['log']['level'] )
120
- || ( 2 == $this->config['tools']['log']['level'] && is_user_logged_in() )
121
- ) {
122
- $is_single = Helper::is_single();
123
  }
124
-
125
- $params = [
126
- 'sampling_active' => (int) $this->config['tools']['sampling']['active'],
127
- 'sampling_rate' => $this->config['tools']['sampling']['rate'],
128
- 'ajax_url' => esc_url_raw(rest_url('wordpress-popular-posts/v1/popular-posts')),
129
- 'ID' => $is_single,
130
- 'token' => wp_create_nonce('wp_rest'),
131
- 'lang' => $lang,
132
- 'debug' => WP_DEBUG
133
- ];
134
- $json_script = '<script type="application/json" id="wpp-json">' . json_encode($params) . '</script>';
135
-
136
- $tag = $json_script . "\n" . $tag;
137
  }
138
 
139
  return $tag;
89
  }
90
 
91
  // Enqueue WPP's library.
92
+ $is_single = 0;
93
+
94
+ if (
95
+ ( 0 == $this->config['tools']['log']['level'] && ! is_user_logged_in() )
96
+ || ( 1 == $this->config['tools']['log']['level'] )
97
+ || ( 2 == $this->config['tools']['log']['level'] && is_user_logged_in() )
98
+ ) {
99
+ $is_single = Helper::is_single();
100
+ }
101
+
102
+ wp_register_script('wpp-js', plugin_dir_url(dirname(dirname(__FILE__))) . 'assets/js/wpp.min.js', [], WPP_VERSION, false);
103
+ $params = [
104
+ 'sampling_active' => (int) $this->config['tools']['sampling']['active'],
105
+ 'sampling_rate' => (int) $this->config['tools']['sampling']['rate'],
106
+ 'ajax_url' => esc_url_raw(rest_url('wordpress-popular-posts/v1/popular-posts')),
107
+ 'ID' => (int) $is_single,
108
+ 'token' => wp_create_nonce('wp_rest'),
109
+ 'lang' => function_exists('PLL') ? $this->translate->get_current_language() : 0,
110
+ 'debug' => (int) WP_DEBUG
111
+ ];
112
+ wp_enqueue_script('wpp-js');
113
+ wp_add_inline_script('wpp-js', json_encode($params), 'before');
114
  }
115
 
116
  /**
130
  function convert_inline_js_into_json($tag, $handle, $src)
131
  {
132
  if ( 'wpp-js' === $handle ) {
133
+ if ( false !== strpos($tag, 'type') ) {
134
+ $tag = preg_replace("%[ ]type=[\'\"]text\/javascript[\'\"]%", ' type="application/json" id="wpp-json"', $tag, 1);
135
+ } else {
136
+ $pos = strpos($tag, '>');
137
+ $tag = substr_replace($tag, ' type="application/json" id="wpp-json">', $pos, 1);
 
 
 
 
 
 
138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
  return $tag;
wordpress-popular-posts.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: WordPress Popular Posts
17
  * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
18
  * Description: A highly customizable widget that displays the most popular posts on your blog.
19
- * Version: 5.2.1
20
  * Author: Hector Cabrera
21
  * Author URI: https://cabrerahector.com/
22
  * License: GPL-2.0+
@@ -29,7 +29,7 @@ if ( ! defined( 'WPINC' ) ) {
29
  die();
30
  }
31
 
32
- define('WPP_VERSION', '5.2.1');
33
  define('WPP_MIN_PHP_VERSION', '5.4');
34
  define('WPP_MIN_WP_VERSION', '4.9');
35
 
16
  * Plugin Name: WordPress Popular Posts
17
  * Plugin URI: https://wordpress.org/plugins/wordpress-popular-posts/
18
  * Description: A highly customizable widget that displays the most popular posts on your blog.
19
+ * Version: 5.2.2
20
  * Author: Hector Cabrera
21
  * Author URI: https://cabrerahector.com/
22
  * License: GPL-2.0+
29
  die();
30
  }
31
 
32
+ define('WPP_VERSION', '5.2.2');
33
  define('WPP_MIN_PHP_VERSION', '5.4');
34
  define('WPP_MIN_WP_VERSION', '4.9');
35