#14256 closed defect (bug) (wontfix)
register_sidebar() loses track of its widgets when moved
Reported by: | wjm | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
I have registered a sidebar container, setting a name,
for example
register_sidebar( array( 'name' => __( 'Test Widget' ), ) );
if you move the order in which it gets registered (let's say, you register it first and then you decide to move it, and register second), all the widgets inside it will get lost.
this is due to the ID being generated by default based on its order number. so when you change the order, you change the ID, and everything is lost.
attached is a patch that: when given a title, it sets the id by default based on the title, and not on the ORDER NUMBER.
It only uses the order number when no title is given.
Attachments (1)
Change History (5)
#1
@
14 years ago
I left the prefix "sidebar-" for the ID when set by default, it can be removed, but it is good to have it so you know it has been set by default.
#2
@
14 years ago
- Cc dangayle added
+1
I hate how WP screws up sidebars when you register a new one.
#3
@
14 years ago
- Milestone Awaiting Review deleted
- Resolution set to wontfix
- Status changed from new to closed
This will break existing installations.
Just register your sidebar with an explicit ID.
register_sidebar( array( 'name' => __( 'Test Widget' ), 'id' => 'test-widget', ) );
#4
@
14 years ago
We could use an option to keep track of a mapping between sidebar titles and generated IDs. Whenever register_sidebar()
is called without an explicit ID, check the map. If there's an entry, use it. If not, generate a unique ID and add it to the map. Not sure how to keep the map from exploding after lots of theme switches.
sets the id based on the title, not on the order it has been registered