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));
- The topic ‘Only Buttons option default to show all not working’ is closed to new replies.