[wp-trac] [WordPress Trac] #17979: Avoid losing widgets when switching themes

WordPress Trac wp-trac at lists.automattic.com
Mon Jul 4 16:49:51 UTC 2011


#17979: Avoid losing widgets when switching themes
--------------------------+------------------------------
 Reporter:  lancewillett  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Widgets       |     Version:  3.2
 Severity:  major         |  Resolution:
 Keywords:  dev-feedback  |
--------------------------+------------------------------

Comment (by lancewillett):

 Here's my suggested solution:

 Add a third step to {{{retrieve_widgets()}}} to move all to first
 registered sidebar after "good ones" and "same number of sidebars" checks.
 {{{switch_themes()}}} should call the widget switch function explicitly,
 instead of relying on it being called from {{{dynamic_sidebar}}} or other
 functions.

  1. Get number of registered sidebars in old theme
  2. Get number of registered sidebars in new theme

  - If number of sidebars are the same in both themes, transfer widgets
 exactly from sidebar to sidebar regardless of the sidebar ID values.
  - If number of sidebars are not the same, put all widgets in first
 registered sidebar.
  - If new theme's number is 0 (no registered sidebars in new theme), put
 all widgets into Inactive. '''This should be the only case where any
 widgets go to Inactive.'''

 This looks like it will need to happen in {{{retrieve_widgets()}}} in
 {{{wp-admin/widgets.php}}} (starting around line 66).

 Then in {{{wp_get_sidebars_widgets()}}} improve the case 2 to follow this
 same logic. (Seems like switch_theme() should run the retrieve_widgets
 function and there shouldn't be the same code in two places.)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17979#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list