WPIntell

Source evidence

[Plugin: Easy Popular Posts] show=false does not work

Easy Popular Posts · support · 2011-03-01T11:26:00+00:00

complaintsentiment
mediumseverity
0.86relevance
4replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 31 rows with source links

19.4% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

25 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Bart McLeod unresolved
<?php if (function_exists('popularPosts')) { $populars = popularPosts('show=false'); if (is_array($populars)) { foreach ($populars as $popular) { var_dump($popular); } } } ?> I tried the above, following your FAQ from the plugin repository. But show=false does not return the links, it just spits them out as if false was not in the parameters. Am I doing something wrong? I will look into the code later. http://wordpress.org/extend/plugins/easy-popular-posts/ 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

Comments

4 shown
Bart McLeod 2011-03-01T12:42:00+00:00

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.

Bart McLeod 2011-03-01T12:48:00+00:00

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>"; }

Bart McLeod 2011-03-01T12:50:00+00:00

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?

christopherross 2011-03-01T13:23:00+00:00

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