[wp-trac] [WordPress Trac] #19846: Specify 'primary' sidebar, so widgets land in correct sidebar when changing themes

WordPress Trac noreply at wordpress.org
Tue Sep 8 01:12:01 UTC 2015


#19846: Specify 'primary' sidebar, so widgets land in correct sidebar when changing
themes
------------------------------------+------------------------------
 Reporter:  billerickson            |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  Widgets                 |     Version:  3.3
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |     Focuses:
------------------------------------+------------------------------
Changes (by welcher):

 * keywords:  needs-patch dev-feedback => dev-feedback has-patch


Comment:

 I've added a patch that does the following:

 1. Adds an `is_primary` argument to `register_sidebar()` with a default of
 `false`
 2. Adds a new function called `wp_get_primary_widget_areas` that loops
 `$wp_registered_sidebars` and returns an array of all areas marked as
 'is_primary - this is a bit naive at the moment as it only adds them as
 they are found in the array but the framework is there to do more moving
 forward.
 3. Adds a check in `switch_theme()` to see if the current them has a
 primary area and uses `set_transient()` to store it temporarily
 4. Added logic in `retrieve_widgets()` to look for a primary widget area
 in the new theme and assign content to it.

 Would love any feedback.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/19846#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list