Skip to content

Commit e99fd77

Browse files
committed
Improve caching.
1 parent 25c75ed commit e99fd77

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/wp-includes/global-styles-and-settings.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,18 +261,13 @@ function ( $item ) {
261261
*
262262
* @since 6.2.0
263263
*
264-
* @param boolean $clear_cache Whether the cache should be cleared and theme support recomputed. Default is false.
265-
*
266264
* @return boolean
267265
*/
268-
function wp_theme_has_theme_json( $clear_cache = false ) {
269-
static $theme_has_support = null;
270-
271-
if ( true === $clear_cache ) {
272-
$theme_has_support = null;
273-
}
274-
275-
if ( null !== $theme_has_support ) {
266+
function wp_theme_has_theme_json() {
267+
$cache_key = 'theme_has_support';
268+
$cache_found = false;
269+
$theme_has_support = wp_cache_get( $cache_key, '', false, $cache_found );
270+
if ( $cache_found ) {
276271
return $theme_has_support;
277272
}
278273

@@ -284,6 +279,8 @@ function wp_theme_has_theme_json( $clear_cache = false ) {
284279
$theme_has_support = is_readable( get_template_directory() . '/theme.json' );
285280
}
286281

282+
wp_cache_set( $cache_key, $theme_has_support );
283+
287284
return $theme_has_support;
288285
}
289286

@@ -294,6 +291,6 @@ function wp_theme_has_theme_json( $clear_cache = false ) {
294291
*
295292
*/
296293
function wp_theme_clean_theme_json_cached_data() {
297-
wp_theme_has_theme_json( true );
294+
wp_cache_delete( 'theme_has_support' );
298295
WP_Theme_JSON_Resolver::clean_cached_data();
299296
}

0 commit comments

Comments
 (0)