Well, I looked into the code and found why it does not work.
if ( $ns_options['show'] ) {
echo $popular;
} else {
return $popular;
}
The above bit of code should obviously be:
if ( $ns_options['show'] !== 'false') {
echo $popular;
} else {
return $popular;
}
Since all the options are extracted as strings, string ‘false’ converts to boolean true if you just check if it is set. Instead, you should do a check for the exact string ‘false’.
And then, after changing the code in this way, my snippet will still not work, because the result is not an array. This is not wrong by the way.
Why would I like to change the behavior? [maybe it already exists, I have to dig in further]. Well, I would like the first of the popular posts to show the excerpt and the title only for the rest of them.
The same applies to:
if ( $ns_options['credit'] !== 'false' ) {
$popular .= "<li style='opacity:0.4;filter:alpha(opacity=40);'><a href='http://thisismyurl.com/downloads/wordpress/plugins/easy-popular-posts/?source=" . urlencode(get_bloginfo('url')) . "' style='opacity:0.4;filter:alpha(opacity=40);' target='_blank'>Easy Popular Posts by Christopher Ross</a></li>";
}
I have refactored your plugin code to allow for separate retrieval of the popular posts as an array and fixed the two bugs mentioned above.
Do you have an repository or e-mail where I can post the altered plugin so that you can use it if you like?
Hi Bart, thanks for addressing that. I try my best to keep the plugins updated and tested, it’s surprising to me that this was not working as I’ve used it myself for many years without issue.
If you could send the plugin to me (info@thisismyurl.com) I’ll review it and update the version here on WordPress.org as soon as possible.
Chris