Skip to content

Commit

Permalink
Use hashed key built using stringified theme.json
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Oct 21, 2024
1 parent 827f9f0 commit 51f26dc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,11 @@ public static function get_resolved_theme_uris( $theme_json ) {
return $resolved_theme_uris;
}

$current_stylesheet_directory = get_stylesheet_directory();
if ( $current_stylesheet_directory && ! empty( static::$resolved_theme_uris_cache[ $current_stylesheet_directory ] ) ) {
return static::$resolved_theme_uris_cache[ $current_stylesheet_directory ];
$theme_json_data = $theme_json->get_raw_data();
$resolved_theme_uris_cache_key = md5( wp_json_encode( $theme_json_data ) );

if ( ! empty( static::$resolved_theme_uris_cache[ $resolved_theme_uris_cache_key ] ) ) {
return static::$resolved_theme_uris_cache[ $resolved_theme_uris_cache_key ];
}

$theme_json_data = $theme_json->get_raw_data();
Expand Down Expand Up @@ -917,9 +919,7 @@ public static function get_resolved_theme_uris( $theme_json ) {
}
}
}
if ( $current_stylesheet_directory ) {
static::$resolved_theme_uris_cache[ $current_stylesheet_directory ] = $resolved_theme_uris;
}
static::$resolved_theme_uris_cache[ $resolved_theme_uris_cache_key ] = $resolved_theme_uris;
return $resolved_theme_uris;
}

Expand Down

0 comments on commit 51f26dc

Please sign in to comment.