• Resolved Dexter0015

    (@improvedline)


    Hi,

    I needed a way to know if the sidebar/corral have any widgets in order to add specials classes in my theme and I didn’t find any method to do it in the plugin files, so I made my own :

    I added it in the “backwards-compat-functions.inc” file :

    /**
     * Check if sidebar/corral cotaint widgets or not
     */
    function ww_is_active_sidebar($corral_slug) {
        global $widget_wrangler;
        if(count($widget_wrangler->page_widgets[$corral_slug]) > 0) {
            return true;
        }
        else {
            return false;
        }
    }

    So you just need to call it in your theme like so :
    ww_is_active_sidebar('your-corral-slug');

    Where ‘your-corral-slug’ should be replace by the corral you need to check.

    Hope it help.

    https://www.ads-software.com/plugins/widget-wrangler/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi improvedline,

    This looks good! Seems like it could be a very useful concept, and I will include it in the next release.

    One thing, the function name ww_is_active_sidebar should be ww_is_active_corral. I’m not a fan of the word ‘sidebar’ at all, because it’s not fully representative of its use. In WW 2.x+ I use “sidebar” to mean WordPress’s implementation of a group of widgets, and “corral” to mean Widget Wrangler’s implementation of a group of widgets. Since this deals with WW’s implementation (checking to see if widgets exist in a corral on this page), we should use the word corral.

    I’ll include this in the next release with the function name ww_is_active_corral, so if you change your implementation, you’ll be next-release-ready!

    Let me know what you think,
    Jonathan

    Thread Starter Dexter0015

    (@improvedline)

    Hi Jonathan,

    You’re right, and I already change my implementation in my WIP project.

    I’m glad you like it.

    Plugin Author Jonathan Daggerhart

    (@daggerhart)

    Hi improvedline,

    This is included in the most recent version 2.1.4 – https://plugins.trac.www.ads-software.com/browser/widget-wrangler/trunk/common/backwards-compat-functions.inc?rev=1036724#L24

    Let me know if you run into any issues with this.

    Thanks,
    Jonathan

    Thread Starter Dexter0015

    (@improvedline)

    Hi Jonathan,

    I already updated two sites and didn’t notice any problem (both on WP 4.0.1).

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘New theme compatibility function’ is closed to new replies.