WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/25/17 16:18:31 (4 months ago)
Author:
obenland
Message:

Widgets: Merge orphaned widgets on theme switch

Merges orphaned widgets into the inactive sidebar when switching themes.

Props bpayton.
See #39693.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets.php

    r41590 r41594  
    11481148    } 
    11491149 
    1150  
    11511150    // Discard invalid, theme-specific widgets from sidebars. 
    11521151    $sidebars_widgets = _wp_remove_unregistered_widgets( $sidebars_widgets, $registered_widgets_ids ); 
     
    12151214            $new_sidebars_widgets[ $sidebar ] = $existing_sidebars_widgets[ $sidebar ]; 
    12161215            unset( $existing_sidebars_widgets[ $sidebar ] ); 
    1217         } else { 
     1216        } else if ( ! array_key_exists( $sidebar, $new_sidebars_widgets ) ) { 
    12181217            $new_sidebars_widgets[ $sidebar ] = array(); 
    12191218        } 
Note: See TracChangeset for help on using the changeset viewer.