#5352 closed defect (bug) (fixed)
register_sidebars does not handle names or multiple calls correctly
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.5 | Priority: | normal |
Severity: | normal | Version: | 2.3.1 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
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
Ups... there where an error in the patch. It has been fixed now and the patch file have been replaced.