Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#6071 closed defect (bug) (wontfix)

register_sidebars should allow name to be an array

Reported by: AaronCampbell Owned by: mdawaffe
Milestone: Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch needs-testing
Focuses: Cc:


register_sidebars allows you to give a name with a %d in it, but you can't register multiple sidebars with unique names. It seems like you should be able to pass an array of names to be used, like this: register_sidebars(array('name'=>array('left','right'))); Which would create two sidebars, one named left, and one named right.

Attachments (1)

wordpress-widgets.diff (694 bytes) - added by AaronCampbell 10 years ago.
Fix for register_sidebars

Download all attachments as: .zip

Change History (11)

10 years ago

Fix for register_sidebars

#1 @AaronCampbell
10 years ago

Well, there was a problem in the diff AND in the description. I fixed the diff, and the register_sidebars call should look like this: register_sidebars(2, array('name'=>array('left','right')));

#2 @ryan
10 years ago

  • Owner changed from anonymous to mdawaffe

#3 @AaronCampbell
10 years ago

Any idea where we stand on this? The patch is working great for me, even with 2.5

#4 @AaronCampbell
10 years ago

  • Milestone changed from 2.6 to 2.5.1

#5 @mdawaffe
10 years ago

How would (array) $argsname? match up with (string) $argsid??

#6 @AaronCampbell
10 years ago

Honestly, I've never used the ID option there, so I guess I overlooked it. I suppose we could either accept another array that we assume is in the same order as the name, or we could accept an array of arrays, each one containing name, id, etc.

It seems like it might be even easier to push more of the processing to register_sidebar(). For example, if there is only one sidebar, why aren't we passing it straight to sidebar? If there is more than one to add, it seems like we should check if $args is an array of string or an array of arrays. If it's an array of strings, we should call register_sidebar($args) $number times. If it's an array of arrays, then we should loop through $args, calling register_sidebar() for each, either using the [0] index for any extras (for example, $args contains 4 arrays, but 5 sidebars were requested to be added), or passing nothing to register_sidebar(), letting it use the defaults.

#7 @ryan
10 years ago

  • Milestone changed from 2.5.2 to 2.9

Milestone 2.5.2 deleted

#8 @AaronCampbell
10 years ago

  • Milestone changed from 2.9 to 2.8

#9 @ryan
9 years ago

  • Component changed from General to Widgets

#10 @Denis-de-Bernardy
9 years ago

  • Milestone 2.8 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

ticket has been open and ignored for over a year, and you can do the same with register_sidebar() calls in a foreach loop.

Note: See TracTickets for help on using tickets.