Avoid losing widgets when switching themes - take one, props aaroncampbell, see #17979

git-svn-id: https://develop.svn.wordpress.org/trunk@18630 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2011-09-02 22:13:55 +00:00
parent 46773a16ea
commit 4782c3dc6f
4 changed files with 140 additions and 97 deletions
+8 -1
View File
@@ -1248,19 +1248,26 @@ function preview_theme_ob_filter_callback( $matches ) {
function switch_theme($template, $stylesheet) {
global $wp_theme_directories;
$old_theme = get_current_theme();
update_option('template', $template);
update_option('stylesheet', $stylesheet);
if ( count($wp_theme_directories) > 1 ) {
update_option('template_root', get_raw_theme_root($template, true));
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
}
delete_option('current_theme');
$theme = get_current_theme();
if ( is_admin() && false === get_option( "theme_mods_$stylesheet" ) ) {
$default_theme_mods = (array) get_option( "mods_$theme" );
add_option( "theme_mods_$stylesheet", $default_theme_mods );
}
do_action('switch_theme', $theme);
update_option( 'theme_switched', $old_theme );
do_action( 'switch_theme', $theme );
}
/**