Allow switch_theme() to take a single $stylesheet argument.
It now effectively has two function definitions: function switch_theme( $stylesheet ) function switch_theme( $template, $stylesheet ) fixes #21075. git-svn-id: http://core.svn.wordpress.org/trunk@21131 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
08efb40e98
commit
3a215028ea
|
@ -953,13 +953,11 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||||
if ( $theme != get_stylesheet() ) // If not current
|
if ( $theme != get_stylesheet() ) // If not current
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
// Ensure stylesheet name hasnt changed after the upgrade:
|
// Ensure stylesheet name hasn't changed after the upgrade:
|
||||||
// @TODO: Note, This doesn't handle the Template changing, or the Template name changing.
|
|
||||||
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
|
if ( $theme == get_stylesheet() && $theme != $this->result['destination_name'] ) {
|
||||||
$theme_info = $this->theme_info();
|
wp_clean_themes_cache();
|
||||||
$stylesheet = $this->result['destination_name'];
|
$stylesheet = $this->result['destination_name'];
|
||||||
$template = $theme_info->get_template();
|
switch_theme( $stylesheet );
|
||||||
switch_theme($template, $stylesheet, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Time to remove maintenance mode
|
//Time to remove maintenance mode
|
||||||
|
|
|
@ -20,7 +20,7 @@ if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
|
||||||
$theme = wp_get_theme( $_GET['stylesheet'] );
|
$theme = wp_get_theme( $_GET['stylesheet'] );
|
||||||
if ( ! $theme->exists() || ! $theme->is_allowed() )
|
if ( ! $theme->exists() || ! $theme->is_allowed() )
|
||||||
wp_die( __( 'Cheatin’ uh?' ) );
|
wp_die( __( 'Cheatin’ uh?' ) );
|
||||||
switch_theme($_GET['template'], $_GET['stylesheet']);
|
switch_theme( $theme->get_stylesheet() );
|
||||||
wp_redirect( admin_url('themes.php?activated=true') );
|
wp_redirect( admin_url('themes.php?activated=true') );
|
||||||
exit;
|
exit;
|
||||||
} elseif ( 'delete' == $_GET['action'] ) {
|
} elseif ( 'delete' == $_GET['action'] ) {
|
||||||
|
|
|
@ -475,7 +475,7 @@ final class WP_Customize_Manager {
|
||||||
// Temporarily stop previewing the theme to allow switch_themes()
|
// Temporarily stop previewing the theme to allow switch_themes()
|
||||||
// to operate properly.
|
// to operate properly.
|
||||||
$this->stop_previewing_theme();
|
$this->stop_previewing_theme();
|
||||||
switch_theme( $this->get_template(), $this->get_stylesheet() );
|
switch_theme( $this->get_stylesheet() );
|
||||||
$this->start_previewing_theme();
|
$this->start_previewing_theme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -650,15 +650,17 @@ function preview_theme_ob_filter_callback( $matches ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches current theme to new template and stylesheet names.
|
* Switches the theme.
|
||||||
|
*
|
||||||
|
* Accepts one argument: $stylesheet of the theme. It also accepts an additional function signature
|
||||||
|
* of two arguments: $template then $stylesheet. This is for backwards compatibility.
|
||||||
*
|
*
|
||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
* @uses do_action() Calls 'switch_theme' action, passing the new theme.
|
* @uses do_action() Calls 'switch_theme' action, passing the new theme.
|
||||||
*
|
*
|
||||||
* @param string $template Template name
|
* @param string $stylesheet Stylesheet name
|
||||||
* @param string $stylesheet Stylesheet name.
|
|
||||||
*/
|
*/
|
||||||
function switch_theme( $template, $stylesheet ) {
|
function switch_theme( $stylesheet ) {
|
||||||
global $wp_theme_directories, $sidebars_widgets;
|
global $wp_theme_directories, $sidebars_widgets;
|
||||||
|
|
||||||
if ( is_array( $sidebars_widgets ) )
|
if ( is_array( $sidebars_widgets ) )
|
||||||
|
@ -666,7 +668,13 @@ function switch_theme( $template, $stylesheet ) {
|
||||||
|
|
||||||
$old_theme = wp_get_theme();
|
$old_theme = wp_get_theme();
|
||||||
$new_theme = wp_get_theme( $stylesheet );
|
$new_theme = wp_get_theme( $stylesheet );
|
||||||
$new_name = $new_theme->get('Name');
|
|
||||||
|
if ( func_num_args() > 1 ) {
|
||||||
|
$template = $stylesheet;
|
||||||
|
$stylesheet = func_get_arg( 1 );
|
||||||
|
} else {
|
||||||
|
$template = $new_theme->get_template();
|
||||||
|
}
|
||||||
|
|
||||||
update_option( 'template', $template );
|
update_option( 'template', $template );
|
||||||
update_option( 'stylesheet', $stylesheet );
|
update_option( 'stylesheet', $stylesheet );
|
||||||
|
@ -676,6 +684,8 @@ function switch_theme( $template, $stylesheet ) {
|
||||||
update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
|
update_option( 'stylesheet_root', get_raw_theme_root( $stylesheet, true ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$new_name = $new_theme->get('Name');
|
||||||
|
|
||||||
update_option( 'current_theme', $new_name );
|
update_option( 'current_theme', $new_name );
|
||||||
|
|
||||||
if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
|
if ( is_admin() && false === get_option( 'theme_mods_' . $stylesheet ) ) {
|
||||||
|
@ -706,17 +716,17 @@ function validate_current_theme() {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) {
|
if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) {
|
||||||
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
|
switch_theme( WP_DEFAULT_THEME );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
|
if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
|
||||||
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
|
switch_theme( WP_DEFAULT_THEME );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
|
if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
|
||||||
switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
|
switch_theme( WP_DEFAULT_THEME );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue