[wp-trac] [WordPress Trac] #5352: register_sidebars does not handle names or multiple calls correctly

WordPress Trac wp-trac at lists.automattic.com
Wed Nov 14 12:47:54 GMT 2007


#5352: register_sidebars does not handle names or multiple calls correctly
---------------------+------------------------------------------------------
 Reporter:  watson   |       Owner:  anonymous
     Type:  defect   |      Status:  new      
 Priority:  normal   |   Milestone:  2.5      
Component:  General  |     Version:  2.3.1    
 Severity:  normal   |    Keywords:           
---------------------+------------------------------------------------------
 In the function `register_sidebars()` in `wp-includes/widgets.php` the
 `$args['name']` attribute is not filtered through `sprintf()`. This means
 that the following call to `register_sidebars()` will have unexpected
 results:

 {{{
 register_sidebars(2, array('name' => 'Foobar %d'));
 }}}

 Instead of producing two sidebars with the names ''Foobar 1'' and ''Foobar
 2'' it will produce two sidebars with the same name: ''Foobar %d''.

 Secondly, multiple calls to `register_sidebars()` will fail if you do not
 specifically supply the `$args['id']` attribute. This is because
 `register_sidebars()` maintains an internal counter that auto-generates an
 id for the specific sidebar (if one is not given as an argument). This
 counter re-starts at `1` on each call to `register_sidebars()`,
 effectively overwriting previously created sidebars on subsequent calls.

 Example:
 {{{
 register_sidebars(2, array('name' => 'Foo %d'));
 register_sidebars(2, array('name' => 'Bar %d'));
 }}}

 This will only create 2 sidebars - not 4. The two sidebars that will be
 created will be the ones from the last call: `Bar %d`

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


More information about the wp-trac mailing list