• Bart McLeod

    (@mcleodspacewebnl)


    <?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/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Bart McLeod

    (@mcleodspacewebnl)

    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.

    Thread Starter Bart McLeod

    (@mcleodspacewebnl)

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

    Thread Starter Bart McLeod

    (@mcleodspacewebnl)

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Easy Popular Posts] show=false does not work’ is closed to new replies.