Widgets: Always try restoring widget assignments
For code-historic reasons, restoring widget assignments would not be attempted if there were no sidebars to map. Restoring previous assignments is something unrelated to sidebar mappings however, so now it will be attempted on every theme switch. See #42719. git-svn-id: https://develop.svn.wordpress.org/trunk@42374 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1c2b0762c7
commit
43d9a479cf
@ -1219,6 +1219,7 @@ function retrieve_widgets( $theme_changed = false ) {
|
||||
* Compares a list of sidebars with their widgets against a whitelist.
|
||||
*
|
||||
* @since 4.9.0
|
||||
* @since 4.9.2 Always tries to restore widget assignments from previous data, not just if sidebars needed mapping.
|
||||
*
|
||||
* @param array $existing_sidebars_widgets List of sidebars and their widget instance IDs.
|
||||
* @return array Mapped sidebars widgets.
|
||||
@ -1261,10 +1262,8 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) {
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no old sidebars left, then we're done.
|
||||
if ( empty( $existing_sidebars_widgets ) ) {
|
||||
return $new_sidebars_widgets;
|
||||
}
|
||||
// If there are more sidebars, try to map them.
|
||||
if ( ! empty( $existing_sidebars_widgets ) ) {
|
||||
|
||||
/*
|
||||
* If old and new theme both have sidebars that contain phrases
|
||||
@ -1319,6 +1318,7 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) {
|
||||
} // endforeach foreach ( $wp_registered_sidebars as $new_sidebar => $args )
|
||||
} // endforeach ( $slug_group as $slug )
|
||||
} // endforeach ( $common_slug_groups as $slug_group )
|
||||
}
|
||||
|
||||
// Move any left over widgets to inactive sidebar.
|
||||
foreach ( $existing_sidebars_widgets as $widgets ) {
|
||||
@ -1329,7 +1329,7 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) {
|
||||
|
||||
// Sidebars_widgets settings from when this theme was previously active.
|
||||
$old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' );
|
||||
$old_sidebars_widgets = $old_sidebars_widgets['data'];
|
||||
$old_sidebars_widgets = isset( $old_sidebars_widgets['data'] ) ? $old_sidebars_widgets['data'] : false;
|
||||
|
||||
if ( is_array( $old_sidebars_widgets ) ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user