Skip to content

Commit

Permalink
Widgets: Merge orphaned widgets on theme switch
Browse files Browse the repository at this point in the history
Merges orphaned widgets into the inactive sidebar when switching themes.

Props bpayton.
See #39693.

Built from https://develop.svn.wordpress.org/trunk@41594


git-svn-id: http://core.svn.wordpress.org/trunk@41427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
obenland committed Sep 25, 2017
1 parent 9597082 commit eea0e5f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41593';
$wp_version = '4.9-alpha-41594';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down
3 changes: 1 addition & 2 deletions wp-includes/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,6 @@ function retrieve_widgets( $theme_changed = false ) {
}
}


// Discard invalid, theme-specific widgets from sidebars.
$sidebars_widgets = _wp_remove_unregistered_widgets( $sidebars_widgets, $registered_widgets_ids );
$sidebars_widgets = wp_map_sidebars_widgets( $sidebars_widgets );
Expand Down Expand Up @@ -1214,7 +1213,7 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) {
if ( in_array( $sidebar, $existing_sidebars, true ) ) {
$new_sidebars_widgets[ $sidebar ] = $existing_sidebars_widgets[ $sidebar ];
unset( $existing_sidebars_widgets[ $sidebar ] );
} else {
} else if ( ! array_key_exists( $sidebar, $new_sidebars_widgets ) ) {
$new_sidebars_widgets[ $sidebar ] = array();
}
}
Expand Down

0 comments on commit eea0e5f

Please sign in to comment.