Dynamic Widgets 1.3.3

I’ve just made version 1.3.3 of Dynamic Widgets available for download. In this new release the following has been added:

  • Added an internal filter when checking for widget options to make the plugin faster. (1.3.2)
  • Added Custom Post Types support for WordPress 3.0.
  • Added WPML support for static pages, category pages, category in single posts and custom post types.
  • Bugfix for not resetting checked count when enabling individual posts with authors and/or category set.



UPDATE: As a follow up on the comment from Michael I have released version 1.3.4 with a fix for the minor flaw.

26 Comments to “Dynamic Widgets 1.3.3”

  • This plugin is absolutely awesome – it’s so good I think it is a must have feature that should have been in WordPress by default. Thank you. 🙂

    • Thank you so much for your kind words, Steven! 🙂

  • Warning: Invalid argument supplied for foreach() in /var/www/63/html/wp-content/plugins/dynamic-widgets/dynwid_admin_save.php on line 203

    Warning: Cannot modify header information – headers already sent by (output started at /var/www/63/html/wp-content/plugins/dynamic-widgets/dynwid_admin_save.php:203) in /var/www/web63/html/wp-includes/pluggable.php on line 890

    Michael

    • Thanks for the comment. I’ve found the problem. I noticed also it doesn’t infuence the behaviour of the plugin itself. It’s just a minor flaw. I just fixed it in the development version.

  • thank you very mutch, i love you plugin in too. its so easy

  • First – I love what this plugin can do.

    But… Maybe I’m missing something. I have developed a theme for WP 3 that includes widget areas above and below the content. The theme uses is_active_sidebar() and dynamic_sidebar() to display sidebars. If there are no widgets in the sidebar, then nothing is displayed. However, when using Dyanamic Widgets for a widget area with only one widget, the function is_active_sidebar() return true even if the only widgets is hidden on that page, resulting in an widget area with nothing in it (my area has a border, so it is really obvious.)

    So is there anything I can do to not display the sidebar if it is active but “empty” because of Dynamic Widgets settings? Is there a filter for is_active_sidebar you could use to give desired behavior.

    Thanks.

    • Hi Bruce,
      Thanks for your comment.

      When Dynamic Widgets is removing widgets, they are removed from the global array $wp_registered_widgets. So, either way, the theme is too early to check is_active_sidebar() or the plugin is too late removing the widgets. Dynamic Widgets starts removing the widgets when wp_head() is called. Earlier is unfortunately not possible, cause before that $wp_registered_widgets is not available. As far as I know, when a dynamic sidebar is empty the dynamic_sidebar() function returns false. Maybe that helps?

  • That doesn’t seem like the answer because themes don’t call is_active_sidebar until after wp_head is done – all the head code has been generated before the header.php code is called. And having dynamic_sidebar() return false also doesn’t help because you have to generate the sidebar div before it is called.

    Maybe the theme has to look directly at $wp_registered_widgets directly instead of relying on is_active_sidebar. But it is a puzzle because the call to is_active_sidebar does come after wp_head is finished.

    Thanks for the reply.

    • Hi Bruce,
      Just a thought I’m playing with: What about using output buffering for that? Like:
      ob_start();
      $success = dynamic_sidebar($index);
      $content = ob_get_clean();
      if ($success) {
      do_output_div($content);
      }

  • I will try that. Thanks! Will let you know if it works.

  • That works! Thanks for the idea.

    • Great! You’re welcome. Thanks for letting me know.

  • One more thing – does your plugin implement a ‘sidebars_widgets’ filter? Essentially, is_active_sidebar return true if the array of widgets passed to that filter is not empty. And this gets called after wp_head. So if you do implement the filter, perhaps it isn’t working right.

    My theme is a child theme of the new standard Twenty Ten theme. Unfortunately, the way Twenty Ten’s code is written doesn’t even try to use is_active_sidebar for the primary sidebar – it just generates three default widgets if the area is empty. So what happens if there is only one widget in the primary sidebar, and it is hidden on a page, Twenty Ten goes ahead and displays the three default widgets. I tested this.

    The Twenty Ten secondary widget does call is_active_sidebar and would behave properly if is_active_sidebar worked.

    My own theme adds two new widget areas at the top and bottom of the
    content area, and now work correctly if all widgets are hidden thanks to your suggestion, but I haven’t fixed Twenty Ten’s sidebars.

    Just thought you might be interested in this. If you get any feedback from Twenty Ten users having the primary sidebar not working right with a single widget, let me know. I could fix the problem in sidebars.php, and you could then recommend my child theme as a way to fix the problem because one of the choices of my child is a pure Twenty Ten look. I haven’t decided if I want to fix the problem or not, but I think one great use of your plugin is to generate a special announcement in the sidebar that only shows on some pages. And someone might put the announcement in the primary sidebar, and other stuff in the secondary sidebar.

    So if either of us gets some demand for this particular situation, I’ll fix the logic for the primary and secondary sidebars as well.

    • No, I don’t use filters. The whole removing process is done by juggeling with the $wp_registered_widgets array.

      The function is_active_sidebar() calls the function wp_get_sidebars_widgets() which retrieves the widgets from the database and fills (when empty) the $wp_registered_widgets array. So, that’s the reason it returns true. I do however see now there is an apply_filters(‘sidebars_widgets’) in wp_get_sidebars_widgets(). If Dynamic Widgets hooks into that, is_active_sidebar() might return the correct boolean. I’m going to look into that. Thanks for pointing that out. 🙂

      Many themes are using a default widget display policy. Pretty bad for Dynamic Widgets as it looks like the plugin isn’t working correctly. The only way to prevent such a thing is making sure one widget remains in the sidebar. Or -as you suggested- changing the code in sidebars.php. If a Twenty Ten user comes to me with this particulair problem, I’ll point them to you.

  • I am using the dynamics widget plugin and its acting up a bit. When I make certain widgets dynamic for certain pages, its taking the widget away for all pages and not pages I only specify.

    I am using wordpress 3.0. I have about 90 pages for my site.

    Any thoughts for me?

    Cheers

    Trey

    • Hi Trey, The 90 pages you have created are all created via the normal WordPress pages option? You’re not using something like JH Portfolio?

  • Hello,

    I am so excited about your plugin, Dynamic Widgets 1.3.4 and I installed it with no problem. I tried out to display all widgets except ONE post that needs a whole page to fill the content. That doesn’t work. The blog I am working on has WordPress3.0.1 and the theme is Terrane Tribune by RocketTheme. Perhaps the theme blocks the widgets in all pages but it did show all widgets in the home page. Hmmm…. did I miss something important ?

    Thanks,
    jan

  • I’d like to add….

    I toggled with Terrane Tribune Settings for subpages with Main and Right columns, and it works with all widgets EXCEPT one post. This post has no widgets however the right column is still there with a blank sidebar. How do I make this post to be a whole page without a blank sidebar ?

    Sorry…

  • Hi Jan,

    I think you’re hitting into more or less the same problem Bruce had. You can read about it starting from comment #6 in this post. Your theme probably uses the WP function is_active_sidebar() to check if a sidebar should appear. The perfect way to check for that. However, because of the use of Dynamic widgets, that particulair function returns a wrong value. I’ve been looking into this to see if it’s possible to let is_active_sidebar() return the correct value. It is possible, but because of the nature the way it has to work, I’m afraid it will dramaticly slow down the running of the plugin. At the moment I’m looking into a way to speed up that process.

    So, until now I don’t have a solution for you right now, other than if you have a bit PHP programming knowledge, you could change the code of the theme a bit to have the sidebar checked before outputting it to the screen. A piece of example code for that you can find in comment #9 of this post.

    Hope this helps.

  • Hi Jacco,

    Thanks for the reply! I have a very little PHP programming so I’m trying to figure out where I put the code you just mentioned. Where do I put this code:

    ob_start();
    $success = dynamic_sidebar($index);
    $content = ob_get_clean();
    if ($success) {
    do_output_div($content);
    }

    Thanks,
    Jan

    • Hi Jan,

      Please note this code is just example code. You have to adapt it to reflect the needs of the theme. You have to find out in your theme where the sidebar is called which remains on empty on screen. I think the best place to start looking / digging in your theme is in sidebar.php (if that’s available of course).

  • If you want to see the fix in action, I implemented it in my theme – Twenty Ten Weaver (available from my web site or WordPress.org as 2010 Weaver). The code is used in the page.php file. (I did not fix it for the main sidebars as supported by the Twenty Ten parent – just for my added top/bottom widget areas.) But the suggested fix works perfectly.

  • Hello Jacco!

    I have been setting up a wordpress network and recently had to move it all to a new server. Everything went smooth as a baby bottom, except the Dynamic Widget plugin 🙁

    Now I can’t change any of the on/off settings – the ones with additional checkboxes (author etc) works quite ok- they all end up with the default On state. If I go diving into the database and change the fields there, the Dynamic Widget edit screen shows the changes and they work. If I then manage to press the save settings button – every main setting changes back to the default On state.

    I am not sure this really is the plugin – since it worked like a charm before the move, but all the other 10+ plugins manage the moved without any changes…

    Do you have any ideas on where I can take a looksie?

    And sorry – the website is not on the Internet – it’s on a company internal site…

    regards,
    Frank

    • Hi Frank,
      Apologies for the bit late reply. Have been away a few days.
      I have to admit, I’m not sure what happenned that’s causing the trouble. I would recommend (I understand this is not an ideal solution) to reset everything by uninstalling the plugin and re-installing it. You can uninstall Dynamic Widgets by clicking on the ‘Advanced >’ link in the Dynamic Widgets overview screen and then pressing the ‘Uninstall’ button.

  • The reset everything option is valid – the new site is not fully operational just yet. 🙂

    But – I have uninstalled and removed every unce of the widget, then reinstalled it. I tried different combo’s of activating the main site first, then a few undersites and vice versa. No luck 🙁

    Thanks for your effort – and another thing:
    Your widgets is amongst the few must-have widgets for my wordpress installation!

    • Are you using the MU of WP? Network activation does not work for Dynamic Widgets. But it looks like you were not using that. Can you please send me a dump? You can send it via the bugreport form. Not sure if it helps me to find out what’s going wrong, but it might help.