When restoring sidebars after switching back to an old theme, make sure the saved data matches the theme's current sidebars, fixes #19092

git-svn-id: http://svn.automattic.com/wordpress/trunk@19332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-11-18 06:00:29 +00:00
parent 042635b68c
commit 84c1617da2
1 changed files with 9 additions and 3 deletions

View File

@ -1164,17 +1164,23 @@ function _wp_sidebars_changed() {
function retrieve_widgets() { function retrieve_widgets() {
global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; global $wp_registered_widget_updates, $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets;
$_sidebars_widgets = array();
$sidebars = array_keys($wp_registered_sidebars);
$old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' ); $old_sidebars_widgets = get_theme_mod( 'sidebars_widgets' );
if ( is_array( $old_sidebars_widgets ) ) { if ( is_array( $old_sidebars_widgets ) ) {
// time() that sidebars were stored is in $old_sidebars_widgets['time'] // time() that sidebars were stored is in $old_sidebars_widgets['time']
$_sidebars_widgets = $old_sidebars_widgets['data']; $old_sidebars = $old_sidebars_widgets['data'];
// make sure the saved sidebars match
foreach ( $sidebars as $sidebar_id ) {
$_sidebars_widgets[$sidebar_id] = isset($old_sidebars[$sidebar_id]) ? $old_sidebars[$sidebar_id] : array();
}
remove_theme_mod( 'sidebars_widgets' ); remove_theme_mod( 'sidebars_widgets' );
} else { } else {
if ( empty( $sidebars_widgets ) ) if ( empty( $sidebars_widgets ) )
return; return;
$sidebars = array_keys($wp_registered_sidebars);
unset( $sidebars_widgets['array_version'] ); unset( $sidebars_widgets['array_version'] );
$old = array_keys($sidebars_widgets); $old = array_keys($sidebars_widgets);