Opened 17 years ago
Closed 16 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: |
Description
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)
Change History (11)
#1
@
17 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')));
#6
@
17 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.
Fix for register_sidebars