summaryrefslogtreecommitdiffstats
path: root/wp-includes/theme.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--wp-includes/theme.php58
1 files changed, 49 insertions, 9 deletions
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index 89fccdd..7157318 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -153,11 +153,17 @@ function wp_clean_themes_cache( $clear_update_cache = true ) {
* Whether a child theme is in use.
*
* @since 3.0.0
+ * @since 6.5.0 Makes use of global template variables.
+ *
+ * @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
+ * @global string $wp_template_path Path to current theme's template directory.
*
* @return bool True if a child theme is in use, false otherwise.
*/
function is_child_theme() {
- return get_template_directory() !== get_stylesheet_directory();
+ global $wp_stylesheet_path, $wp_template_path;
+
+ return $wp_stylesheet_path !== $wp_template_path;
}
/**
@@ -836,9 +842,26 @@ function switch_theme( $stylesheet ) {
update_option( 'theme_switched', $old_theme->get_stylesheet() );
+ /*
+ * Reset template globals when switching themes outside of a switched blog
+ * context to ensure templates will be loaded from the new theme.
+ */
+ if ( ! is_multisite() || ! ms_is_switched() ) {
+ wp_set_template_globals();
+ }
+
// Clear pattern caches.
- $new_theme->delete_pattern_cache();
- $old_theme->delete_pattern_cache();
+ if ( ! is_multisite() ) {
+ $new_theme->delete_pattern_cache();
+ $old_theme->delete_pattern_cache();
+ }
+
+ // Set autoload=no for the old theme, autoload=yes for the switched theme.
+ $theme_mods_options = array(
+ 'theme_mods_' . $stylesheet => 'yes',
+ 'theme_mods_' . $old_theme->get_stylesheet() => 'no',
+ );
+ wp_set_option_autoload_values( $theme_mods_options );
/**
* Fires after the theme is switched.
@@ -1437,14 +1460,16 @@ function is_random_header_image( $type = 'any' ) {
if ( 'any' === $type ) {
if ( 'random-default-image' === $header_image_mod
|| 'random-uploaded-image' === $header_image_mod
- || ( '' !== get_random_header_image() && empty( $header_image_mod ) )
+ || ( empty( $header_image_mod ) && '' !== get_random_header_image() )
) {
return true;
}
} else {
if ( "random-$type-image" === $header_image_mod ) {
return true;
- } elseif ( 'default' === $type && empty( $header_image_mod ) && '' !== get_random_header_image() ) {
+ } elseif ( 'default' === $type
+ && empty( $header_image_mod ) && '' !== get_random_header_image()
+ ) {
return true;
}
}
@@ -2603,18 +2628,31 @@ function get_theme_starter_content() {
* @since 5.3.0 The `html5` feature now also accepts 'script' and 'style'.
* @since 5.3.0 Formalized the existing and already documented `...$args` parameter
* by adding it to the function signature.
+ * @since 5.4.0 The `disable-custom-gradients` feature limits to default gradients or gradients added
+ * through `editor-gradient-presets` theme support.
* @since 5.5.0 The `core-block-patterns` feature was added and is enabled by default.
* @since 5.5.0 The `custom-logo` feature now also accepts 'unlink-homepage-logo'.
* @since 5.6.0 The `post-formats` feature warns if no array is passed as the second parameter.
* @since 5.8.0 The `widgets-block-editor` feature enables the Widgets block editor.
+ * @since 5.8.0 The `block-templates` feature indicates whether a theme uses block-based templates.
* @since 6.0.0 The `html5` feature warns if no array is passed as the second parameter.
+ * @since 6.1.0 The `block-template-parts` feature allows to edit any reusable template part from site editor.
+ * @since 6.1.0 The `disable-layout-styles` feature disables the default layout styles.
+ * @since 6.3.0 The `link-color` feature allows to enable the link color setting.
+ * @since 6.3.0 The `border` feature allows themes without theme.json to add border styles to blocks.
+ * @since 6.5.0 The `appearance-tools` feature enables a few design tools for blocks,
+ * see `WP_Theme_JSON::APPEARANCE_TOOLS_OPT_INS` for a complete list.
*
* @global array $_wp_theme_features
*
* @param string $feature The feature being added. Likely core values include:
* - 'admin-bar'
* - 'align-wide'
+ * - 'appearance-tools'
* - 'automatic-feed-links'
+ * - 'block-templates'
+ * - 'block-template-parts'
+ * - 'border'
* - 'core-block-patterns'
* - 'custom-background'
* - 'custom-header'
@@ -2626,21 +2664,24 @@ function get_theme_starter_content() {
* - 'dark-editor-style'
* - 'disable-custom-colors'
* - 'disable-custom-font-sizes'
+ * - 'disable-custom-gradients'
+ * - 'disable-layout-styles'
* - 'editor-color-palette'
* - 'editor-gradient-presets'
* - 'editor-font-sizes'
* - 'editor-styles'
* - 'featured-content'
* - 'html5'
+ * - 'link-color'
* - 'menus'
* - 'post-formats'
* - 'post-thumbnails'
* - 'responsive-embeds'
* - 'starter-content'
* - 'title-tag'
- * - 'wp-block-styles'
* - 'widgets'
* - 'widgets-block-editor'
+ * - 'wp-block-styles'
* @param mixed ...$args Optional extra arguments to pass along with certain features.
* @return void|false Void on success, false on failure.
*/
@@ -2777,7 +2818,7 @@ function add_theme_support( $feature, ...$args ) {
* the constant is always accurate (and is not defined later, overriding our value).
* As stated above, the first value wins.
* Once we get to wp_loaded (just-in-time), define any constants we haven't already.
- * Constants are lame. Don't reference them. This is just for backward compatibility.
+ * Constants should be avoided. Don't reference them. This is just for backward compatibility.
*/
if ( defined( 'NO_HEADER_TEXT' ) ) {
@@ -3582,7 +3623,6 @@ function _wp_customize_include() {
* @since 4.7.0
* @access private
*
- * @global wpdb $wpdb WordPress database abstraction object.
* @global WP_Customize_Manager $wp_customize Customizer instance.
*
* @param string $new_status New post status.
@@ -3590,7 +3630,7 @@ function _wp_customize_include() {
* @param WP_Post $changeset_post Changeset post object.
*/
function _wp_customize_publish_changeset( $new_status, $old_status, $changeset_post ) {
- global $wp_customize, $wpdb;
+ global $wp_customize;
$is_publishing_changeset = (
'customize_changeset' === $changeset_post->post_type