Blog

WordPress

Posted on — Last updated on January 27, 2024

WordPress Popular Posts 6.3: New Shortcode To Display Views Count + PHP 8 Compatibility Improvements

New shortcode to render views count plus PHP 8 improvements, 6.3 is yet another small release that still packs a punch!

Version 6.3 introduces a new shortcode called [wpp_views_count] that shows the number of times a given post / page has been viewed (this post, for example, has 674 views so far!) Also, 6.3 introduces yet more small fixes / enhancements to improve PHP 8 compatibility.

Continuing with the semi-quick release cycle that’s been happening for the past couple of months, version 6.3.0 is here to introduce a new feature, fix a fatal error that can occur when a certain PHP extension isn’t enabled on the server, and also to improve compatibility with PHP 8.1 and newer.

New Shortcode: [wpp_views_count]

This one is long overdue.

For quite some time now users of the WordPress Popular Posts plugin have been asking whether there’s a shortcode to render the views count of a post / page and the answer so far has been “no, but there’s an unofficial one on the forum that you can use”.

Version 6.3.0 finally introduces this shortcode officially as part of the plugin. If you happen to be using the “unofficial” one on your site, please remove it (you may find this function or some variation of it somewhere inside your theme’s functions.php file) and let the official one do the job instead.

To learn more about the shortcode and the parameters it can take please check out [wpp_views_count] documentation.

Improved PHP 8 Support

This release, just like some of the most recent ones, includes code enhancements to make sure that WordPress Popular Posts can run nicely with newer versions of PHP.

@ispreview from the WordPress.org forums reported a couple of instances where the plugin was triggering some PHP notices due to stuff being flagged as deprecated on PHP 8.2. Likewise, @dimalifragis also notified about a particular PHP notice being triggered under PHP 8.1. All of these reported deprecation notices have been taken care of so thank you both for helping make WordPress Popular Posts a better plugin!

Fixed PHP fatal error when mbstring is not available

mbstring is a PHP extension (also known as “module”) that bundles a set of string related functions to handle multibyte characters (eg. accented characters).

WordPress Popular Posts relies on this extension to handle special characters -like accents in French writing for example- when truncating text that may contain them such as the post title or the post excerpt, or while parsing your popular posts list before rendering it on screen (which, too, may contain special characters).

The mbstring extension is not enabled by default on some servers though and its absence may cause some PHP errors due to the plugin expecting it to be available (like this for example).

Future versions of the plugin may include some more strict checks to prevent fatal errors from happening and so please make sure that your site meets WordPress Popular Posts’ technical requirements before using it.

Minor Updates & Hotfixes

6.3.4

Version 6.3.4, released on November 9 2023, patches an issue where non-HTML5 friendly WordPress themes would cause the plugin to fail to work as intended after the WordPress 6.4 release.

Among other things, WordPress 6.4 introduced a change where inline JavaScript code would be wrapped in a CDATA block automatically for themes that do not explicitly declare support for HTML5 tags (see changeset 56687).

This particular change unexpectedly caused WordPress Popular Posts to not be able to read its inline JSON data which prevented it from tracking visits, loading popular posts lists via AJAX, etc. If you are being affected by this issue please update to version 6.3.4 as soon as possible, and if you’re using a caching plugin on your site (eg. WP Super Cache) make sure to flush its cache afterwards.

Version 6.3.4 also introduces a small QoL feature that allows users to reset their default thumbnail to the one WordPress Popular Posts includes out-of-the-box should anyone for some reason need to.

New Reset Thumbnail button

6.3.3

Version 6.3.3, released on October 4 2023, patches an Stored Cross Site Scripting (XSS) vulnerability that allowed authenticated users that have the Contributor role or higher to inject malicious web scripts into the page. Props to the Patchstack team for reporting this issue.

6.3.2

Version 6.3.2, released on August 28 2023, fixes a PHP notice coming from the [wpp] shortcode that might be displayed on the front-end for sites that have WP_DEBUG set to TRUE.

This release also removes some legacy AJAX code from the codebase as the plugin hasn’t used it in ages. This change should be of no consequence for most -if not all- people out there but I’m still leaving a note about it here in case someone was using it for some reason.

6.3.1

Version 6.3.1, released on August 27 2023, fixes a fatal error caused by a single typo in a namespace call (yes, even I make that kind of mistakes from time to time).

This fatal error should not have affected that many of you out there since it was patched up pretty quickly but for those that were affected by it and that are finding yourselves unable to access your WP Dashboard please follow these instructions so you can regain access to it. Apologies for any inconvenience(s) that this may have caused.