Opened 14 years ago
Closed 11 years ago
#18671 closed enhancement (duplicate)
Allow themes to set default widgets
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.3 |
Component: | Widgets | Keywords: | |
Focuses: | Cc: |
Description
Rather than having to use a hard-coded fallback HTML sidebar, it'd be cool if a theme could set up default widgets.
#17979 will somewhat remove the need for this but it could still be useful.
Change History (8)
#2
in reply to:
↑ 1
@
14 years ago
Replying to ocean90:
Without testing: Is it not possible via
update_option( 'sidebars_widgets', array() )
?
I mean we do it in core too, see [18643].
It's possible but you have to know the structure of an "internal" option.
Ideally we should have a function a theme can call / or an extention of register_sidebar() which says put these widgets in here when the sidebar is empty / new.
#6
@
13 years ago
- Cc ryan@… added
Definitely something that's needed. I see a use case for this with multisite installs where rolling out a new site should get a default set of widgets. Core basically updates the options table with a serialized array, while it can be duplicated, it's certainly not ideal.
It's something I'd like to jumpstart for 3.6 since it's too late to accomplish in the 3.5 cycle. Any core devs want to suggest an ideal approach to this before I start working on a patch?
Maybe something as simple as adding a 'contains' parameter to register_sidebar() which would include an array of widget names? That's one of the options Westi suggested and I think it makes the most sense.
#7
@
13 years ago
Several months ago I wrote something this hacky class: https://gist.github.com/3110599. It's a little different approach.
With this code you can register a widget to a sidebar by code. To have a class/function for this you can easily pass settings to a widget. If you do this with register_sidebar() it's getting a mess and complicated.
Without testing: Is it not possible via
update_option( 'sidebars_widgets', array() )
?I mean we do it in core too, see [18643].