Support » Plugin: Widget Logic » [Plugin: Widget Logic] is_active_sidebar() doesn't work

Viewing 15 replies - 1 through 15 (of 16 total)
  • I’ve rewritten the function widget_logic_redirect_callback()and removed widget_logic_redirected_callback(). Now it works as I want.

    function widget_logic_redirect_callback(){
      global $_wp_sidebars_widgets;
      $wl_options = get_option('widget_logic');
      $sidebars_widgets = get_option('sidebars_widgets');
      foreach ($sidebars_widgets as $id => $widgets) {
        if ($id != 'wp_inactive_widgets' && !empty($widgets)) {
          foreach ($widgets as $widget => $widget_id) {
            $wl_value=(stristr($wl_value, "return"))?$wl_value:"return (".$wl_value.");";

    * speechless *

    well almost.

    i’ve sat on my code for far too long (since WP2.1??) happy that it did the job. But you may have hit on a much simpler approach. not only simpler, but less prone to some of the problems caused by themes that play games with bespoke queries that mess up the conditional tags.

    I’ll do some testing and if it works out and you have no objection I’ll consider incorporating that approach (and a variation on the code above) in the next beta/release.

    (though it would mean rethinking how to do the widget_content filter)

    It will be good if you take this code to your next release.
    I’ve seen how it is done in ‘Widget context’ plugin, but that plugin less flexible and takes more resources.

    For less resources consumption it will be good to divide plugin into ‘admin’ and ‘front-end’ parts like this:

    if (is_admin())
      include_once 'wl-admin.php';
      include_once 'wl-frontend.php';}

    PS: The string ‘unset($sidebars_widgets[$id][$widget]);’ in the code above is redundant.

    This is the fix that I have been looking for! Unfortunately I get an error after editing the plugin code:

    Warning: Invalid argument supplied for foreach() in /home/.../public_html/wp-content/plugins/widget-logic/widget_logic.php on line 140

    This is the line that causes the error:

    foreach ($widgets as $widget => $widget_id) {

    How can I fix this?

    Got the same message. Would love to hear the solutions.

    Sorry, but I cann’t reproduce this error.
    My WP 3.0.1 and fixed Widget Logic 0.47 works fine.

    I am using WP 3.1 but it might be that I made an error when changing the plugin with code.

    I would therefore really appreciate it if you therefore could upload the complete version of your modified plugin.


    This is the full code of fixed widget_logic.php:

    Thanks Vasya! The code you uploaded works!

    Awesome. Thanks!

    I have found that updating this breaks the layout again though.

    Updating to 0.48 that is. I fixed the issue by updating the version number on this code. Thanks again.

    It is a pitty that the author of this plugin still has not implemented this solution. In the plugin code there even is a comment about the issue:

    // intercept  registered widgets - redirect them and put each ID on the end of the params
    // perhaps there is a way to just intercept the ones that are used??

    So yes, there is a way to do this 🙂

    Yes, it is a pity. I think the best solution is for you to release your version while giving credit to this author and then everyone should be happy.

    I am a lazy lazy coder. also very conservative. If I get time to update I’ll look at a beta that includes this alternative approach and see what sort of reaction it gets – I’m just wary of breaking lots of sites, to the point where I’d consider having *both* approaches in and a setting to toggle between them to maximise compatibility.

    as you can see I’m basically making excuses to do nothing. sorry. never say never though. i’ll take a look at that pastbin code – and again thanks to the original contributor and everyone else who’s chipped in.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Plugin: Widget Logic] is_active_sidebar() doesn't work’ is closed to new replies.