[wp-trac] [WordPress Trac] #12606: register_sidebars(n) fails to register multiple sidebars when 'id' argument defined

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 14 10:26:36 UTC 2010


#12606: register_sidebars(n) fails to register multiple sidebars when 'id' argument
defined
--------------------------+-------------------------------------------------
 Reporter:  minusfive     |       Owner:  azaozz                    
     Type:  defect (bug)  |      Status:  new                       
 Priority:  normal        |   Milestone:  2.9.3                     
Component:  Widgets       |     Version:  2.9.2                     
 Severity:  major         |    Keywords:  widgets, register_sidebars
--------------------------+-------------------------------------------------
 When using default args for 'register_sidebars()' as defined on Codex:

 {{{
 $args = array(
     'name'          => 'My Custom Sidebar %d',
     'id'            => 'my-custom-sidebar-$i',
     'before_widget' => '<li id=\"%1$s\" class=\"widget %2$s\">',
     'after_widget'  => '</li>',
     'before_title'  => '<h2 class=\"widgettitle\">',
     'after_title'   => '</h2>' );
 }}}

 'id' argument won't get the '$i' variable value, thus won't be unique for
 each sidebar. Because all sidebars will end up using the same id, each
 iteration will override the previous sidebar. This obviously causes the
 system to register only 1 sidebar (the last iteration).

 If 'id' argument is simply not defined and the function is allowed to use
 the default all sidebars are created, which is OK unless you insert
 another sidebar before, in which case all settings are lost. This is
 because the default 'id' argument for multiple sidebars is dependent on
 the sidebar's position in the wp_registered_sidebars array.

 Proposed solution attached.

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


More information about the wp-trac mailing list