From c23cc4cd13d8e3d476f5859ad1287e333b26c776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 1 Dec 2022 09:15:01 +0100 Subject: [PATCH 01/12] wp_get_global_stylesheet: substitute 1-minute transient by object cache --- .../global-styles-and-settings.php | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index c625166524b63..9d0ff775b7c13 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -83,18 +83,12 @@ function wp_get_global_styles( $path = array(), $context = array() ) { * @return string Stylesheet. */ function wp_get_global_stylesheet( $types = array() ) { - // Return cached value if it can be used and exists. - // It's cached by theme to make sure that theme switching clears the cache. - $can_use_cached = ( - ( empty( $types ) ) && - ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) && - ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) && - ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) && - ! is_admin() - ); - $transient_name = 'global_styles_' . get_stylesheet(); + // Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme developers workflow. + $can_use_cached = empty( $types ) && ! WP_DEBUG; + $cache_key = 'wp_get_global_stylesheet'; + $cache_group = 'theme_json'; if ( $can_use_cached ) { - $cached = get_transient( $transient_name ); + $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { return $cached; } @@ -148,15 +142,10 @@ function wp_get_global_stylesheet( $types = array() ) { } $styles_rest = $tree->get_stylesheet( $types, $origins ); } - $stylesheet = $styles_variables . $styles_rest; - if ( $can_use_cached ) { - // Cache for a minute. - // This cache doesn't need to be any longer, we only want to avoid spikes on high-traffic sites. - set_transient( $transient_name, $stylesheet, MINUTE_IN_SECONDS ); + wp_cache_set( $cache_key, $stylesheet, $cache_group ); } - return $stylesheet; } @@ -283,3 +272,31 @@ function wp_theme_has_theme_json() { function wp_clean_theme_json_cache() { WP_Theme_JSON_Resolver::clean_cached_data(); } + +/** + * Tell the cache mechanisms not to persist theme.json data across requests. + * The data stored under this cache group: + * + * - wp_get_global_stylesheet + * + * There is some hooks consumers can use to modify parts + * of the theme.json logic. + * See https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ + * + * The rationale to make this cache group non persistent is to make sure derived data + * from theme.json is always fresh from the potential modifications done via hooks + * that can use dynamic data (modify the stylesheet depending on some option, + * or settings depending on user permissions, etc.). + * + * A different alternative considered was to invalidate the cache upon certain + * events such as options add/update/delete, user meta, etc. + * It was judged not enough, hence this approach. + * See https://github.com/WordPress/gutenberg/pull/45372 + * + * @since 6.1.2 + * @access private + */ +function _wp_add_non_persistent_theme_json_cache_group() { + wp_cache_add_non_persistent_groups( 'theme_json' ); +} +add_action( 'plugins_loaded', '_wp_add_non_persistent_theme_json_cache_group' ); From f84f94ccc51226632a7189a4337016242601bc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 1 Dec 2022 16:23:04 +0100 Subject: [PATCH 02/12] Move hook to default-filters.php --- src/wp-includes/default-filters.php | 1 + src/wp-includes/global-styles-and-settings.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 4e6340700cc15..018c53110cccf 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -352,6 +352,7 @@ add_action( 'after_switch_theme', '_wp_sidebars_changed' ); add_action( 'wp_print_styles', 'print_emoji_styles' ); add_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); +add_action( 'plugins_loaded', '_wp_add_non_persistent_theme_json_cache_group' ); if ( isset( $_GET['replytocom'] ) ) { add_filter( 'wp_robots', 'wp_robots_no_robots' ); diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 9d0ff775b7c13..e36b4029e1b13 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -299,4 +299,3 @@ function wp_clean_theme_json_cache() { function _wp_add_non_persistent_theme_json_cache_group() { wp_cache_add_non_persistent_groups( 'theme_json' ); } -add_action( 'plugins_loaded', '_wp_add_non_persistent_theme_json_cache_group' ); From 87078300ccf0b56289ee068dbeb513d4353fdf70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:11:44 +0100 Subject: [PATCH 03/12] Make theme_json as non-persistent at load --- src/wp-includes/default-filters.php | 1 - .../global-styles-and-settings.php | 45 +++++++------------ src/wp-includes/load.php | 2 +- 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 018c53110cccf..4e6340700cc15 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -352,7 +352,6 @@ add_action( 'after_switch_theme', '_wp_sidebars_changed' ); add_action( 'wp_print_styles', 'print_emoji_styles' ); add_action( 'plugins_loaded', '_wp_theme_json_webfonts_handler' ); -add_action( 'plugins_loaded', '_wp_add_non_persistent_theme_json_cache_group' ); if ( isset( $_GET['replytocom'] ) ) { add_filter( 'wp_robots', 'wp_robots_no_robots' ); diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index e36b4029e1b13..764d4ec349271 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -85,8 +85,24 @@ function wp_get_global_styles( $path = array(), $context = array() ) { function wp_get_global_stylesheet( $types = array() ) { // Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme developers workflow. $can_use_cached = empty( $types ) && ! WP_DEBUG; - $cache_key = 'wp_get_global_stylesheet'; + /** + * By using the 'theme_json' group, this data is marked to be non-persistent across requests. + * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php + * + * The rationale for this is to make sure derived data from theme.json + * is always fresh from the potential modifications done via hooks + * that can use dynamic data (modify the stylesheet depending on some option, + * settings depending on user permissions, etc.). + * See some of the existing hooks to modify theme.json behaviour: + * https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ + * + * A different alternative considered was to invalidate the cache upon certain + * events such as options add/update/delete, user meta, etc. + * It was judged not enough, hence this approach. + * See https://github.com/WordPress/gutenberg/pull/45372 + */ $cache_group = 'theme_json'; + $cache_key = 'wp_get_global_stylesheet'; if ( $can_use_cached ) { $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { @@ -272,30 +288,3 @@ function wp_theme_has_theme_json() { function wp_clean_theme_json_cache() { WP_Theme_JSON_Resolver::clean_cached_data(); } - -/** - * Tell the cache mechanisms not to persist theme.json data across requests. - * The data stored under this cache group: - * - * - wp_get_global_stylesheet - * - * There is some hooks consumers can use to modify parts - * of the theme.json logic. - * See https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ - * - * The rationale to make this cache group non persistent is to make sure derived data - * from theme.json is always fresh from the potential modifications done via hooks - * that can use dynamic data (modify the stylesheet depending on some option, - * or settings depending on user permissions, etc.). - * - * A different alternative considered was to invalidate the cache upon certain - * events such as options add/update/delete, user meta, etc. - * It was judged not enough, hence this approach. - * See https://github.com/WordPress/gutenberg/pull/45372 - * - * @since 6.1.2 - * @access private - */ -function _wp_add_non_persistent_theme_json_cache_group() { - wp_cache_add_non_persistent_groups( 'theme_json' ); -} diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 4c212086df34e..c2450e582f958 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -753,7 +753,7 @@ function wp_start_object_cache() { ) ); - wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); + wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } $first_init = false; From d39b5e4a697a30c646c47613d5baefa31996c7d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:38:45 +0100 Subject: [PATCH 04/12] Add test_switching_themes_recalculates_stylesheet --- tests/phpunit/tests/theme/wpGetGlobalStylesheet.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php index 710f77d0caf0d..651749bb20ca5 100644 --- a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php +++ b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php @@ -270,4 +270,12 @@ public function test_should_enqueue_stored_styles() { 'Registered styles with handle of "wp-style-engine-my-styles" do not match expected value from the Style Engine store.' ); } + + public function test_switching_themes_recalculates_stylesheet() { + $stylesheet_for_default_theme = wp_get_global_stylesheet(); + switch_theme( 'block-theme' ); + $stylesheet_for_block_theme = wp_get_global_stylesheet(); + $this->assertStringNotContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_default_theme, 'custom font size (100px) not present for default theme' ); + $this->assertStringContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_block_theme, 'custom font size (100px) is present for block theme' ); + } } From 95fd03acfa9b3c6016f4634a2678ec93fd63cc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Tue, 13 Dec 2022 15:44:06 +0100 Subject: [PATCH 05/12] Add non-persistent group to all places --- src/wp-includes/global-styles-and-settings.php | 2 +- src/wp-includes/ms-blogs.php | 4 ++-- tests/phpunit/includes/abstract-testcase.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 764d4ec349271..a356f6110ab79 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -87,7 +87,7 @@ function wp_get_global_stylesheet( $types = array() ) { $can_use_cached = empty( $types ) && ! WP_DEBUG; /** * By using the 'theme_json' group, this data is marked to be non-persistent across requests. - * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php + * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php and other places. * * The rationale for this is to make sure derived data from theme.json * is always fresh from the potential modifications done via hooks diff --git a/src/wp-includes/ms-blogs.php b/src/wp-includes/ms-blogs.php index 0ea6f85627dcb..7ff830e930863 100644 --- a/src/wp-includes/ms-blogs.php +++ b/src/wp-includes/ms-blogs.php @@ -575,7 +575,7 @@ function switch_to_blog( $new_blog_id, $deprecated = null ) { ); } - wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); + wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } } @@ -666,7 +666,7 @@ function restore_current_blog() { ); } - wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); + wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } } diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index bae787a42dee3..fa048cdfa703a 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -401,7 +401,7 @@ public static function flush_cache() { ) ); - wp_cache_add_non_persistent_groups( array( 'counts', 'plugins' ) ); + wp_cache_add_non_persistent_groups( array( 'counts', 'plugins', 'theme_json' ) ); } /** From 6db5380da83cc15bf827867076e0846f0c6e9d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Wed, 14 Dec 2022 09:49:36 +0100 Subject: [PATCH 06/12] Update tests/phpunit/tests/theme/wpGetGlobalStylesheet.php Co-authored-by: Colin Stewart <79332690+costdev@users.noreply.github.com> --- tests/phpunit/tests/theme/wpGetGlobalStylesheet.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php index 651749bb20ca5..193cca0346288 100644 --- a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php +++ b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php @@ -270,8 +270,12 @@ public function test_should_enqueue_stored_styles() { 'Registered styles with handle of "wp-style-engine-my-styles" do not match expected value from the Style Engine store.' ); } - - public function test_switching_themes_recalculates_stylesheet() { + /** + * Tests that switching themes recalculates the stylesheet. + * + * @ticket 56970 + */ + public function test_switching_themes_should_recalculate_stylesheet() { $stylesheet_for_default_theme = wp_get_global_stylesheet(); switch_theme( 'block-theme' ); $stylesheet_for_block_theme = wp_get_global_stylesheet(); From 9c82e0bed628f91be0463ea46d180d4ffe46e3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 15 Dec 2022 17:27:37 +0100 Subject: [PATCH 07/12] Update src/wp-includes/global-styles-and-settings.php Co-authored-by: Andrew Ozz <743931+azaozz@users.noreply.github.com> --- src/wp-includes/global-styles-and-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index a356f6110ab79..90015e05fb719 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -85,7 +85,7 @@ function wp_get_global_styles( $path = array(), $context = array() ) { function wp_get_global_stylesheet( $types = array() ) { // Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme developers workflow. $can_use_cached = empty( $types ) && ! WP_DEBUG; - /** + /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php and other places. * From a0ae74140cd0e7fccc2a169351d2fae5113fee85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 15 Dec 2022 17:38:16 +0100 Subject: [PATCH 08/12] Switch back to default theme --- tests/phpunit/tests/theme/wpGetGlobalStylesheet.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php index 193cca0346288..e1ab84287fa21 100644 --- a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php +++ b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php @@ -279,7 +279,10 @@ public function test_switching_themes_should_recalculate_stylesheet() { $stylesheet_for_default_theme = wp_get_global_stylesheet(); switch_theme( 'block-theme' ); $stylesheet_for_block_theme = wp_get_global_stylesheet(); + $this->assertStringNotContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_default_theme, 'custom font size (100px) not present for default theme' ); $this->assertStringContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_block_theme, 'custom font size (100px) is present for block theme' ); + + switch_theme( WP_DEFAULT_THEME ); } } From 45536da4ca065e72f3068971daf15261a3210006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 16 Dec 2022 09:14:46 +0100 Subject: [PATCH 09/12] Switch back before assertions --- tests/phpunit/tests/theme/wpGetGlobalStylesheet.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php index e1ab84287fa21..a2c0f962d27fb 100644 --- a/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php +++ b/tests/phpunit/tests/theme/wpGetGlobalStylesheet.php @@ -279,10 +279,9 @@ public function test_switching_themes_should_recalculate_stylesheet() { $stylesheet_for_default_theme = wp_get_global_stylesheet(); switch_theme( 'block-theme' ); $stylesheet_for_block_theme = wp_get_global_stylesheet(); + switch_theme( WP_DEFAULT_THEME ); $this->assertStringNotContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_default_theme, 'custom font size (100px) not present for default theme' ); $this->assertStringContainsString( '--wp--preset--font-size--custom: 100px;', $stylesheet_for_block_theme, 'custom font size (100px) is present for block theme' ); - - switch_theme( WP_DEFAULT_THEME ); } } From af0cb51515303ee24c90c74cbe6889cc513821ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Fri, 20 Jan 2023 02:13:34 +0100 Subject: [PATCH 10/12] Add comment about use of WP_DEBUG --- src/wp-includes/global-styles-and-settings.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 90015e05fb719..c4e07cf29a0ae 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -83,7 +83,13 @@ function wp_get_global_styles( $path = array(), $context = array() ) { * @return string Stylesheet. */ function wp_get_global_stylesheet( $types = array() ) { - // Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme developers workflow. + /* + * + * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme + * developer's workflow. + * + * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. + */ $can_use_cached = empty( $types ) && ! WP_DEBUG; /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. From 5477120c2e2f3211a892473a51f965e399bd0c6a Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 26 Jan 2023 12:50:13 -0600 Subject: [PATCH 11/12] Updating formatting and inline comments --- src/wp-includes/global-styles-and-settings.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index c4e07cf29a0ae..545fca8158e65 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -84,31 +84,31 @@ function wp_get_global_styles( $path = array(), $context = array() ) { */ function wp_get_global_stylesheet( $types = array() ) { /* - * * Ignore cache when `WP_DEBUG` is enabled, so it doesn't interfere with the theme * developer's workflow. * * @todo Replace `WP_DEBUG` once an "in development mode" check is available in Core. */ $can_use_cached = empty( $types ) && ! WP_DEBUG; + /* * By using the 'theme_json' group, this data is marked to be non-persistent across requests. - * See `wp_cache_add_non_persistent_groups` in src/wp-includes/load.php and other places. + * @see `wp_cache_add_non_persistent_groups()`. * * The rationale for this is to make sure derived data from theme.json * is always fresh from the potential modifications done via hooks * that can use dynamic data (modify the stylesheet depending on some option, * settings depending on user permissions, etc.). - * See some of the existing hooks to modify theme.json behaviour: - * https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ + * See some of the existing hooks to modify theme.json behavior: + * @see https://make.wordpress.org/core/2022/10/10/filters-for-theme-json-data/ * * A different alternative considered was to invalidate the cache upon certain * events such as options add/update/delete, user meta, etc. * It was judged not enough, hence this approach. - * See https://github.com/WordPress/gutenberg/pull/45372 + * @see https://github.com/WordPress/gutenberg/pull/45372 */ - $cache_group = 'theme_json'; - $cache_key = 'wp_get_global_stylesheet'; + $cache_group = 'theme_json'; + $cache_key = 'wp_get_global_stylesheet'; if ( $can_use_cached ) { $cached = wp_cache_get( $cache_key, $cache_group ); if ( $cached ) { @@ -164,10 +164,12 @@ function wp_get_global_stylesheet( $types = array() ) { } $styles_rest = $tree->get_stylesheet( $types, $origins ); } + $stylesheet = $styles_variables . $styles_rest; if ( $can_use_cached ) { wp_cache_set( $cache_key, $stylesheet, $cache_group ); } + return $stylesheet; } From d9c0909951b2a894d137324c1082a50167a2d114 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Thu, 26 Jan 2023 13:39:26 -0600 Subject: [PATCH 12/12] Delete cache in wp_clean_theme_json_cache() --- src/wp-includes/global-styles-and-settings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/global-styles-and-settings.php b/src/wp-includes/global-styles-and-settings.php index 545fca8158e65..d83562ddb7cae 100644 --- a/src/wp-includes/global-styles-and-settings.php +++ b/src/wp-includes/global-styles-and-settings.php @@ -294,5 +294,6 @@ function wp_theme_has_theme_json() { * @since 6.2.0 */ function wp_clean_theme_json_cache() { + wp_cache_delete( 'wp_get_global_stylesheet', 'theme_json' ); WP_Theme_JSON_Resolver::clean_cached_data(); }