Blog

WordPress

Posted on — Last updated on April 4, 2021

WordPress Popular Posts 5.2 is here!

WordPress Popular Posts 5.2 is yet another performance focused release with a couple of new features plus (minor) bug fixes

Native Lazy Loading, better pageviews caching, pretty numbers and some more features & changes have been included with the release of version 5.2.

With the release of version 5.2, WordPress Popular Posts introduces a couple of performance enhancements plus the usual ration of minor improvements and bug fixes.

JavaScript based Lazy Loading superseded by Native Lazing Loading

WordPress Popular Posts 5.0 introduced the ability to lazy load thumbnails, a feature intended to help improve page loading times (read here for more details.)

Said featured relied heavily on JavaScript for it to work. The problem with this approach is that browsers that have JavaScript disabled (which is rare but it happens) will prevent WPP from displaying the thumbnails. There were also some reports where under specific circumstances third-party scripts could (partially) affect the lazy loading of images.

Fortunately though and since April this year most major browsers out there have adopted the new Native Lazy Load feature, a feature that gives us authors/developers the ability to control over when the browser should start loading images (and iframes) without having to rely on JavaScript.

WordPress Popular Posts' Native Lazy Loading

But what about browsers that don’t provide native lazy loading support, you ask? Well, it’s all good in that regard as well: these browsers will simply ignore the lazy load instruction and continue to load WPP’s thumbnails normally.

Improved Pageviews Cache

The Pageviews Cache, a feature that was first introduced with the release of WordPress Popular Posts 4.2, also saw some minor improvements with this release:

  • The Pageviews Cache will now group views data by minute and not by second which should noticeable reduce the amount of data the plugin stores on the database.
  • The logic has been simplified as well which should make code maintenance a bit easier.

Pretty Numbers!

Up until now, WordPress Popular Posts always displayed raw views/comments count numbers on the front-end which is fine when said numbers aren’t that big (eg. 1,276 views, 300 comments, etc). However for very active sites these numbers can grow quite a lot – say, for example, 20,367,987 views.

Social Media sites (or any site that shows some sort of statistics really) often display these numbers using a “short format” version because it uses way less space, it’s generally easier to read, and conveys the popularity of the content just about the same way as if you were seeing the actual number.

Carter Wilkerson's viral "Nuggs" tweet

From version 5.2 and on, WordPress Popular Posts will also display views/comments count in this format (but only in the front-end, the Stats dashboard will continue to display raw numbers.)

If you prefer having the plugin display the raw numbers instead (as it did on older releases) you can use the wpp_pretiffy_numbers filter hook to disable the feature.

Fixed a few layout issues in widget themes

Early adopters of Widget Themes, a feature that was just recently introduced with version 5.0, reported some minor issues with some of the built-in themes:

  • Posts with multiple categories were displaying them in a weird way.
  • Font sizes in general were a bit off when themed WPP widgets were used on some WordPress themes (eg. the post title was way too small in some cases.)
  • Etc.

All of the reported bugs have been dealt with!

Improved compatibility with Content Security Policy

Content Security Policy (CSP) is an HTTP Header that provides an additional layer of protection against Cross-Site Scripting (XSS), Clickjacking, and other forms of code injection attacks. You can read more about it here: Content Security Policy – An Introduction.

Among other things, CSP can prevent the execution of inline scripts which is great because this reduces the risk of a malicious script injecting code into your posts and pages.

Starting version 5.2, WordPress Popular Posts will remove all instances of inline JS script tags from your site’s front-end, helping making your website more secure if you’re planning to implement CSP on it.

Important: as a side effect of this change WordPress Popular Posts may have compatibility issues with plugins that minify/combine JavaScript code. Read here for more details: Is WordPress Popular Posts compatible with plugins that minify/bundle JavaScript code?

A huge thanks to Jon Scaife for suggesting this change!

Using ACF Images for thumbnails

WordPress Popular Posts includes the ability to set a custom field as the image source to generate popular posts thumbnails. Until now, the feature required that said custom field returned an actual image URL string for the plugin to be able to render the thumbnail on screen.

With the release of version 5.2.0, WordPress Popular Posts now also accepts an attachment ID as a valid value. As a side effect, this also means that custom fields created with Advanced Custom Fields (ACF) -specifically ACF’s Image fields- will also be compatible with WordPress Popular Posts.

Don’t forget to clear your site’s cache!

If you’re using a caching plugin on your website and you’re either installing WordPress Popular Posts for the first time or you’re upgrading from a previous version of the plugin, please remember to flush your site’s cache to make sure WPP 5.2.0 works as expected (refer to your caching plugin’s documentation for more details).

Minor Updates & Hotfixes

  • Version 5.2.4, released on August 26th, 2020, fixes a couple of PHP notices affecting Block Editor users on WordPress 5.5. Also, it fixes a rare PHP warning message that pops up randomly when the Pageviews Cache is enabled.
  • Version 5.2.3, released on August 13th, 2020, addresses a compatibility issue with WordPress 5.5: WordPress 5.5 is injecting an additional ID attribute to WPP’s JSON script, breaking WPP in the process (see here for example). Also, version 5.2.3 improves the compatibility of some widget themes that were partially broken under Internet Explorer 11 (anyone still using IE11 reading this?)
  • Version 5.2.2, released on July 18th, 2020, addresses an issue caused by third-party plugins that minify HTML code. These plugins were converting boolean values in WPP’s JSON object into a format that wasn’t valid JSON, breaking WPP’s ability to track views, load widgets, etc. Aside from that, there are other minor improvements included with this version as well.
  • Version 5.2.1, released on July 12th, 2020, addresses a fatal PHP error affecting some server setups (thanks to everyone who helped test the patch!) and also fixes couple of minor issues, so please upgrade as soon as possible.

Questions? Suggestions? Leave a comment below!