Editor: Read theme.json files stored in styles/ folder only once.

Uses `read_json_file` to access cached file if it exists instead of using `wp_json_file_decode` directly.

Props oandregal, aaronrobertshaw, joemcgill, ramonopoly, isabel_brison.
See #61451.

Built from https://develop.svn.wordpress.org/trunk@58428


git-svn-id: http://core.svn.wordpress.org/trunk@57877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
isabel_brison 2024-06-18 06:02:14 +00:00
parent aeb9f37238
commit e820f8cdf9
2 changed files with 3 additions and 2 deletions

View File

@ -725,6 +725,7 @@ class WP_Theme_JSON_Resolver {
* @since 6.6.0 Added configurable scope parameter to allow filtering
* theme.json partial files by the scope to which they
* can be applied e.g. theme vs block etc.
* Added basic caching for read theme.json partial files.
*
* @param string $scope The scope or type of style variation to retrieve e.g. theme, block etc.
* @return array
@ -751,7 +752,7 @@ class WP_Theme_JSON_Resolver {
}
ksort( $variation_files );
foreach ( $variation_files as $path => $file ) {
$decoded_file = wp_json_file_decode( $path, array( 'associative' => true ) );
$decoded_file = self::read_json_file( $path );
if ( is_array( $decoded_file ) && static::style_variation_has_scope( $decoded_file, $scope ) ) {
$translated = static::translate( $decoded_file, wp_get_theme()->get( 'TextDomain' ) );
$variation = ( new WP_Theme_JSON( $translated ) )->get_raw_data();

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.6-beta2-58427';
$wp_version = '6.6-beta2-58428';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.