From e820f8cdf958cd75fe0eb0ae4e655737bc63c8e4 Mon Sep 17 00:00:00 2001 From: isabel_brison Date: Tue, 18 Jun 2024 06:02:14 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-theme-json-resolver.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-theme-json-resolver.php b/wp-includes/class-wp-theme-json-resolver.php index fca687cfb9..e226644f6f 100644 --- a/wp-includes/class-wp-theme-json-resolver.php +++ b/wp-includes/class-wp-theme-json-resolver.php @@ -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(); diff --git a/wp-includes/version.php b/wp-includes/version.php index d89b721be2..6ee4c4552d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.