From 99bc097e5eb1d751b472b1f6da97548ec3b067c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:52:59 +0200 Subject: [PATCH 1/2] Cache reading theme.json files from styles/ folder. --- src/wp-includes/class-wp-theme-json-resolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index fca687cfb9f1b..e26c4a6eb8f7d 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -751,7 +751,7 @@ public static function get_style_variations( $scope = 'theme' ) { } 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(); From f1cd969e1a47e25fae1b65a9dc409f009aecfadf Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:34:15 +1000 Subject: [PATCH 2/2] Update since comment to reference caching change --- src/wp-includes/class-wp-theme-json-resolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index e26c4a6eb8f7d..e226644f6f6a8 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -725,6 +725,7 @@ private static function style_variation_has_scope( $variation, $scope ) { * @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