Support » Plugin: Reaction Buttons » Only Buttons option default to show all not working

  • Resolved max_Q

    (@max_q)


    Hi,
    In setting up the Reaction Buttons button statistics widget I left the “Show only those buttons” field empty, as the default is to show all. From the install instructions: “only_buttons: comma separated list of buttons to show. Default is to show all.” What happened was the widget showed none instead of all.

    In looking at the code, in reaction_buttons_widget() you are exploding $only_buttons without checking first to see if it’s empty. If it is empty, the array created by explode() seems for some reason to pass the !empty() test in reaction_buttons_get_top_button_posts(), but array_intersect() finds no commonality between $buttons and $only_buttons. $buttons ends up empty and the widget displays nothing. At least that’s what I think is happening.

    I put the following code in after $only_buttons = get_option(‘reaction_buttons_widget_buttons’); in reaction_buttons_widget() in order to not use explode() if $only_buttons is empty. Seems to work OK.

    $only_buttons = empty( $only_buttons ) ? ” : explode(“,”, preg_replace(“/,\s+/”, “,”, $only_buttons));

    Regards

    http://wordpress.org/extend/plugins/reaction-buttons/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jakob Lenfers

    (@jakob42)

    Thanks, I just uploaded the fix, should be available in the repository shortly.

    Tested and works fine. Great job, and thanks for the props.

    BTW, I’m using a little jQuery to update the buttons immediately, rather than waiting for the ajax round trip. I felt it was a more immediate response to clicking. Would you like the code?

    Here’s the site if you want to see it:
    http://www.lastminutelauderdale.com

    Plugin Author Jakob Lenfers

    (@jakob42)

    I had it like that, but the clicks then sometimes where wrong. I get it that the other feels faster but I rather would do it right than fast.

    Right, absolutely. I just put the jQuery on top of what you have, so the button gets updated immediately while the ajax does it’s thing in the background. It doesn’t really matter, usually the ajax is pretty quick.

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Only Buttons option default to show all not working’ is closed to new replies.