WordPress.org

Ready to get started?Download WordPress

Forums

Reaction Buttons
[resolved] Only Buttons option default to show all not working (5 posts)

  1. max_Q
    Member
    Posted 1 year ago #

    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/

  2. Jakob Lenfers
    Member
    Plugin Author

    Posted 1 year ago #

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

  3. max_Q
    Member
    Posted 1 year ago #

    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

  4. Jakob Lenfers
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  5. max_Q
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic