mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
Upgrade: New themes are not automatically installed on upgrade. This can still be explicitly asked for by defining CORE_UPGRADE_SKIP_NEW_BUNDLED as false.
In `populate_options()`, if the theme specified by `WP_DEFAULT_THEME` doesn't exist, fall back to the latest core default theme. If we can't find a core default theme, `WP_DEFAULT_THEME` is the best we can do. Props nacin, jeremyfelt, dd32. See #34306. git-svn-id: https://develop.svn.wordpress.org/trunk@35738 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -753,8 +753,10 @@ function switch_theme( $stylesheet ) {
|
||||
/**
|
||||
* Checks that current theme files 'index.php' and 'style.css' exists.
|
||||
*
|
||||
* Does not check the default theme, which is the fallback and should always exist.
|
||||
* Does not initially check the default theme, which is the fallback and should always exist.
|
||||
* But if it doesn't exist, it'll fall back to the latest core default theme that does exist.
|
||||
* Will switch theme to the fallback theme if current theme does not validate.
|
||||
*
|
||||
* You can use the 'validate_current_theme' filter to return false to
|
||||
* disable this functionality.
|
||||
*
|
||||
@@ -774,22 +776,39 @@ function validate_current_theme() {
|
||||
if ( wp_installing() || ! apply_filters( 'validate_current_theme', true ) )
|
||||
return true;
|
||||
|
||||
if ( get_template() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/index.php') ) {
|
||||
if ( ! file_exists( get_template_directory() . '/index.php' ) ) {
|
||||
// Invalid.
|
||||
} elseif ( ! file_exists( get_template_directory() . '/style.css' ) ) {
|
||||
// Invalid.
|
||||
} elseif ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
|
||||
// Invalid.
|
||||
} else {
|
||||
// Valid.
|
||||
return true;
|
||||
}
|
||||
|
||||
$default = wp_get_theme( WP_DEFAULT_THEME );
|
||||
if ( $default->exists() ) {
|
||||
switch_theme( WP_DEFAULT_THEME );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( get_stylesheet() != WP_DEFAULT_THEME && !file_exists(get_template_directory() . '/style.css') ) {
|
||||
switch_theme( WP_DEFAULT_THEME );
|
||||
return false;
|
||||
/**
|
||||
* If we're in an invalid state but WP_DEFAULT_THEME doesn't exist,
|
||||
* switch to the latest core default theme that's installed.
|
||||
* If it turns out that this latest core default theme is our current
|
||||
* theme, then there's nothing we can do about that, so we have to bail,
|
||||
* rather than going into an infinite loop. (This is why there are
|
||||
* checks against WP_DEFAULT_THEME above, also.) We also can't do anything
|
||||
* if it turns out there is no default theme installed. (That's `false`.)
|
||||
*/
|
||||
$default = WP_Theme::get_core_default_theme();
|
||||
if ( false === $default || get_stylesheet() == $default->get_stylesheet() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_child_theme() && ! file_exists( get_stylesheet_directory() . '/style.css' ) ) {
|
||||
switch_theme( WP_DEFAULT_THEME );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
switch_theme( $default->get_stylesheet() );
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user