mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
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:
@@ -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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user