Skip to content

Commit

Permalink
Cache only the theme json
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal authored and ockham committed Oct 5, 2022
1 parent 2775e75 commit e2704ab
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/wp-includes/class-wp-theme-json-resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,19 +186,22 @@ public static function get_theme_data( $deprecated = array(), $options = array()
}

$options = wp_parse_args( $options, array( 'with_supports' => true ) );
if ( null === static::$theme && null === static::$theme_json_data ) {
if ( null === static::$theme_json_data ) {

$theme_json_data = static::read_json_file( static::get_file_path_from_theme( 'theme.json' ) );
$theme_json_data = static::translate( $theme_json_data, wp_get_theme()->get( 'TextDomain' ) );

/**
* Filters the data provided by the theme for global styles & settings.
*
* @since 6.1.0
*
* @param WP_Theme_JSON_Data Class to access and update the underlying data.
*/

static::$theme_json_data = $theme_json_data;
$theme_json = apply_filters( 'theme_json_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) );
$theme_json_data = $theme_json->get_data();
static::$theme_json_data = $theme_json_data;
static::$theme = new WP_Theme_JSON( $theme_json_data );

if ( wp_get_theme()->parent() ) {
Expand All @@ -213,7 +216,7 @@ public static function get_theme_data( $deprecated = array(), $options = array()
static::$theme = $parent_theme;
}
}

static::$theme = new WP_Theme_JSON( static::$theme_json_data );
if ( ! $options['with_supports'] ) {
return static::$theme;
}
Expand Down

0 comments on commit e2704ab

Please sign in to comment.