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

WordPress Trac wp-trac at lists.automattic.com
Thu Jul 28 06:13:09 UTC 2011


#17979: Avoid losing widgets when switching themes
--------------------------+------------------
 Reporter:  lancewillett  |       Owner:
     Type:  enhancement   |      Status:  new
 Priority:  high          |   Milestone:  3.3
Component:  Widgets       |     Version:  2.9
 Severity:  normal        |  Resolution:
 Keywords:  ux-feedback   |
--------------------------+------------------

Comment (by andrewryno):

 My attempt hasn't been going my way tonight so I thought I'd share my
 approach.

 In retrieve_widgets() in wp-admin/widgets.php, we should be storing the
 inactive widgets in `$sidebars_widgets['wp_inactive_widgets']` not just by
 the ID of the inactive widget, but group them in a nested array by the old
 sidebar ID. Then in the beginning of retrieve_widgets(), the check for
 "known-good" sidebars can be extended to search within
 `$sidebars_widgets['wp_inactive_widgets']` to see if any match in there as
 well.

 With that, any widget that is inactive (from ANY theme activation, not
 just the previous one) could be added to the current theme if it happens
 to have a matching sidebar ID.

 Now, if we store the sidebar name (not just ID) for the inactive widget in
 the newly nested array approach, a UI could be made to go through all of
 those inactive widgets, group them nicely by sidebar name and then give
 the user a dropdown to select a new sidebar.

 I'd love to start implementing this but I'm not sure how to approach it as
 a plugin and testing any code changes directly in core is cumbersome since
 I have to add a widget and change the theme for every refresh.

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


More information about the wp-trac mailing list