Blog

WordPress

Posted on — Last updated on July 5, 2024

WordPress Popular Posts 6.1: Improved PHP 8.1 Support, “Classic” Widget Deprecated

Around 11% of the WordPress community is using PHP 8.0 or higher right now, this release further improves WPP’s compatibility with it

Version 6.1 is a step forward introducing better support for PHP 8.1 (and newer). Also, the “classic” WordPress Popular Posts widget has now been officially deprecated, make sure to migrate over to its block counterpart and/or the [wpp] shortcode as soon as possible.

Without further ado, let’s see what’s new.

Improved PHP 8.1 Support

Over past few months or so PHP 8’s adoption rate by the WordPress community has improved.

A little over a year ago only about 0.3% of all of the WordPress powered websites out there were using PHP 8. At the time of writing we’re sitting at 11%~.

Screenshot of PHP statistics chart as of November 2022

During this time a handful of users have reached out to report a couple of PHP deprecated notices generated by the plugin when used with PHP 8.1. While these notices won’t cause any actual issues (the plugin and the website it is being used on will continue to operate as usual) it’s still nice to fix these notices early on for ease of mind.

The actual notices reported that a specific class within the plugin, WordPressPopularPosts\Container\Container, wasn’t declaring the return types of some of its methods. This particular class inherits some of its properties / methods from another class, ArrayAccess, which does declare its returns types – hence the mismatch and the notices.

Again, this won’t affect the operation of the plugin in any way, not at least until PHP 9 comes out, possibly in a few years from now. Even so, this release fixes these notices so we (you and me) don’t have to worry about them anymore.

While I’m sure that I caught all of the reported deprecation notices, if you’re using PHP 8.1 or newer on your website and find that there are some notices that are still popping up and you’re reasonably sure that they’re being generated by WordPress Popular Posts please let me know and I’ll have a look.

New Filter Hook: wpp_the_date

Version 6.1 introduces a new filter hook called wpp_the_date which will allow developers to manipulate the dates that WordPress Popular Posts displays on screen when rendering your popular posts lists.

This could be useful if for example you wanted to display the last modified date of your posts instead of the publication date, like so: Possible to include date of latest update?

Preventing Views Count Manipulation by Malicious Users

The JPCERT/CC organization, a Japanese group that surveys potential cyber security threats, reached out to report an issue where a malicious user could game the Data Sampling feature to artificially inflate the views count of a particular post / page. While this doesn’t pose any security concerns, it does alter the expected behavior of the plugin when tracking views count.

Version 6.1 addresses this problem so please make sure to update as soon as possible.

Minor Updates & Hotfixes

6.1.4

Version 6.1.4, released on July 14 2023, fixes an issue where the [wpp] shortcode might render empty paragraphs when using custom HTML tags with it. For example, people building popular posts grids via CSS Grid would find that these empty paragraphs were breaking their custom layout.

6.1.4 also fixes a JavaScript error that prevented the popular posts list from loading via AJAX. A “minified” JavaScript file from WordPress Popular Posts contained variable names generated during the minification process that conflicted with third party scripts, causing WPP not to be able to load its popular post list. If your site is using a caching plugin and/or it’s hosting its assets (css files, js files, images, etc) on a CDN flushing the page cache is highly recommended.

Lastly, classic widget’s deprecation notice (see 6.1.2) has been reworded for clarity, letting users know that the widget itself won’t be removed until plugin version 7.0 is released to the public. There is no ETA for that so people seeing this deprecation notice should have enough time to migrate from the classic widget to either the WordPress Popular Posts block or the [wpp] shortcode.

6.1.3

Version 6.1.3, released right after 6.1.2, fixes a rare PHP fatal error that can occur under specific conditions. Props to @winetravelista and @scotttripatrek for reporting the problem on wordpress.org and for helping out debug the issue.

6.1.2

Version 6.1.2, released on June 19 2023, officially deprecates the “classic” WordPress Popular Posts widget. Minor fixes and code enhancements have been included as well.

The “classic” WordPress Popular Posts widget will soon be no more

The WordPress Popular Posts block has been around since version 5.3.4 -released on July 2021- and the general reception seems to have been positive so far.

The classic WordPress Popular Posts widget, on the other hand, has been semi-broken since the introduction of the block-based Widgets Editor. While it still works on the front-end, on the block-based Widgets Editor it’s not that functional.

Also, people using the WordPress Popular Posts “classic” widget with page builders such as Elementor and Divi have reported that there are some compatibility issues, eg. inability to set a widget theme, popular posts list not rendering as expected while editing a post/page with these page builders, etc.

Lastly, there’s also the fact that the future (and even present) of WordPress are blocks (don’t know what a “block” is? Check out The Block Editor and Blocks to get up to speed.) Even if I reverted my decision now there will be a point in the future where all classic widgets -not just WordPress Popular Posts’ widget- will simply stop working, hence the reason why I encourage you all to switch to either the WordPress Popular Posts block or the [wpp] shortcode as soon as you can (see Migration Guide to learn how).

After this update, if you’re using the “classic” WordPress Popular Posts widget on your website you may see a deprecation notice right above your popular posts list to let you know in advance that the popular posts widget is going to be removed from the plugin sometime in the future.

Screenshot of the notice administrators will see on the front-end
Deprecation Notice

This notice is only visible to site administrators. Visitors and users with other roles (eg. editors, authors, etc) wont’ see this message.

The “classic” WordPress Popular Posts widget will stop working once plugin version 7.0 releases some time in the future. To avoid having your popular posts list disappear from your website you should replace the “classic” widget with either the WordPress Popular Posts block or the [wpp] shortcode (see Migration Guide for more details).

If you’re using the Classic Widgets plugin on your site you’ll need to replace the “classic” WordPress Popular Posts widget with the [wpp] shortcode, otherwise you can use the WordPress Popular Posts block (see video above for a demo) or the [wpp] shortcode.

6.1.1

Version 6.1.1, released on November 27 2022, fixes a rare PHP fatal error that can occur during plugin activation.

The plugin relies on a parameter called $network_activate provided by WordPress itself that in theory should always represent a boolean value (true/false). However, it appears that in some instances (and I’m not sure if this is due to a recent change within WordPress) $network_activate can be null instead of true/false which causes the plugin to fail to activate. This release patches that so users can enable the plugin without issues.

Another worth mentioning change is that the WordPress Popular Posts block has been updated too, although it’s a small Quality of Life improvement: links related to customizing the HTML markup of your popular posts list have been added to the block’s edit form for ease of access.

Comments? Questions? Feel free to leave a comment below!