mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-02 11:21:57 +01:00
git-svn-id: http://svn.automattic.com/wordpress/trunk@20033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1e5baa0ca0
commit
b599bef67a
@ -633,7 +633,7 @@ function preview_theme() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prevent theme mods to current theme being used on theme being previewed
|
// Prevent theme mods to current theme being used on theme being previewed
|
||||||
add_filter( 'pre_option_mods_' . get_current_theme(), '__return_empty_array' );
|
add_filter( 'pre_option_theme_mods_' . get_option( 'stylesheet' ), '__return_empty_array' );
|
||||||
|
|
||||||
ob_start( 'preview_theme_ob_filter' );
|
ob_start( 'preview_theme_ob_filter' );
|
||||||
}
|
}
|
||||||
@ -711,37 +711,38 @@ function preview_theme_ob_filter_callback( $matches ) {
|
|||||||
* Switches current theme to new template and stylesheet names.
|
* Switches current theme to new template and stylesheet names.
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
* @uses do_action() Calls 'switch_theme' action on updated theme display name.
|
* @uses do_action() Calls 'switch_theme' action, passing the new theme.
|
||||||
*
|
*
|
||||||
* @param string $template Template name
|
* @param string $template Template name
|
||||||
* @param string $stylesheet Stylesheet name.
|
* @param string $stylesheet Stylesheet name.
|
||||||
*/
|
*/
|
||||||
function switch_theme($template, $stylesheet) {
|
function switch_theme( $template, $stylesheet ) {
|
||||||
global $wp_theme_directories, $sidebars_widgets;
|
global $wp_theme_directories, $sidebars_widgets;
|
||||||
|
|
||||||
if ( is_array( $sidebars_widgets ) )
|
if ( is_array( $sidebars_widgets ) )
|
||||||
set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) );
|
set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) );
|
||||||
|
|
||||||
$old_theme = get_current_theme();
|
$old_theme = wp_get_theme();
|
||||||
|
$new_theme = wp_get_theme( $stylesheet );
|
||||||
|
$new_name = $new_theme->get('Name');
|
||||||
|
|
||||||
update_option('template', $template);
|
update_option( 'template', $template );
|
||||||
update_option('stylesheet', $stylesheet);
|
update_option( 'stylesheet', $stylesheet );
|
||||||
|
|
||||||
if ( count($wp_theme_directories) > 1 ) {
|
if ( count( $wp_theme_directories ) > 1 ) {
|
||||||
update_option('template_root', get_raw_theme_root($template, true));
|
update_option( 'template_root', get_raw_theme_root( $template, true ) );
|
||||||
update_option('stylesheet_root', get_raw_theme_root($stylesheet, true));
|
update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete_option('current_theme');
|
update_option( 'current_theme', $new_name );
|
||||||
$theme = get_current_theme();
|
|
||||||
|
|
||||||
if ( is_admin() && false === get_option( "theme_mods_$stylesheet" ) ) {
|
if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
|
||||||
$default_theme_mods = (array) get_option( "mods_$theme" );
|
$default_theme_mods = (array) get_option( 'mods_' . $new_name );
|
||||||
add_option( "theme_mods_$stylesheet", $default_theme_mods );
|
add_option( "theme_mods_$stylesheet", $default_theme_mods );
|
||||||
}
|
}
|
||||||
|
|
||||||
update_option( 'theme_switched', $old_theme );
|
update_option( 'theme_switched', $old_theme->get('Name') );
|
||||||
do_action( 'switch_theme', $theme );
|
do_action( 'switch_theme', $new_name, $new_theme );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user