Ticket #5352 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

register_sidebars does not handle names or multiple calls correctly

Reported by: watson Assigned to: ryan
Priority: normal Milestone: 2.5
Component: General Version: 2.3.1
Severity: normal Keywords:
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

Attachments

register_sidebars_patch.diff (1.1 kB) - added by watson on 11/14/07 14:16:45.

Change History

11/14/07 14:16:45 changed by watson

  • attachment register_sidebars_patch.diff added.

11/14/07 14:18:51 changed by watson

Ups... there where an error in the patch. It has been fixed now and the patch file have been replaced.

11/15/07 23:40:58 changed by ryan

  • owner changed from anonymous to ryan.

12/14/07 08:06:09 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6381]) Fix registration of multiple sidebars. Props watson. fixes #5352

12/15/07 17:55:14 changed by darkdragon

  • milestone changed from 2.5 to 2.4.

I asssume this was fixed on trunk (2.4).