[wp-trac] [WordPress Trac] #10956: replacement is_active_sidebar - wp-includes/widgets.php

WordPress Trac wp-trac at lists.automattic.com
Wed Oct 14 15:47:48 UTC 2009


#10956: replacement is_active_sidebar - wp-includes/widgets.php
-------------------------+--------------------------------------------------
 Reporter:  Frumph       |       Owner:            
     Type:  enhancement  |      Status:  new       
 Priority:  normal       |   Milestone:  Unassigned
Component:  General      |     Version:  2.9       
 Severity:  normal       |    Keywords:            
-------------------------+--------------------------------------------------
 This uses the new sidebar global and allows for checking via name of the
 sidebar and the #

 {{{
 /**
  * function is_active_sidebar
  * check if a sidebar has widgets based on index number or name
  *
  * @param $index - sidebar name made with
 register_sidebar(array('name'=>'Name of Sidebar'),
  * OR the index # as an int for specific sidebar.
  * @return true if sidebar with $index has widgets, false if not.
  *
  */
 function is_active_sidebar( $index ) {
         global $wp_registered_sidebars, $_wp_sidebars_widgets;
         if ( is_int($index) ) {
                 if
 (!empty($_wp_sidebars_widgets[sanitize_title("sidebar-$index")]) )
                         return true;
         } else {
                 $i = 1;
                 foreach ( $wp_registered_sidebars as $sidebar =>
 $registered_sidebar ) {
                         if ( $index == $registered_sidebar['name'] &&
 !empty($_wp_sidebars_widgets[sanitize_title("sidebar-$i")]) )
                                 return true;
                         $i++;
                 }
         }
         return false;
 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/10956>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list