From a184a821a6cb5e33b8388a97249159de5c8de98b Mon Sep 17 00:00:00 2001 From: Karthik Thayyil Date: Thu, 14 Mar 2024 11:27:21 +0000 Subject: [PATCH 1/4] Remove additional call to theme_json --- src/wp-includes/class-wp-theme-json-data.php | 11 +++++++++++ src/wp-includes/class-wp-theme-json-resolver.php | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php index 6aa8a3971c62d..947fb95139f82 100644 --- a/src/wp-includes/class-wp-theme-json-data.php +++ b/src/wp-includes/class-wp-theme-json-data.php @@ -69,4 +69,15 @@ public function update_with( $new_data ) { public function get_data() { return $this->theme_json->get_raw_data(); } + + /** + * Return theme JSON object. + * + * @since 6.6.0 + * + * @return WP_Theme_JSON + */ + public function get_theme_json() { + return $this->theme_json; + } } diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 44db8364f1092..b37c80c66da79 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -255,8 +255,7 @@ public static function get_theme_data( $deprecated = array(), $options = array() * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. */ $theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) ); - $theme_json_data = $theme_json->get_data(); - static::$theme = new WP_Theme_JSON( $theme_json_data ); + static::$theme = $theme_json->get_theme_json(); if ( $wp_theme->parent() ) { // Get parent theme.json. From a3523d0a28fe3dcc2ed9fb29e8b5b21e4b021980 Mon Sep 17 00:00:00 2001 From: Karthik Thayyil Date: Thu, 14 Mar 2024 12:18:54 +0000 Subject: [PATCH 2/4] cs fixes --- src/wp-includes/class-wp-theme-json-data.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php index 947fb95139f82..fefa68206cb03 100644 --- a/src/wp-includes/class-wp-theme-json-data.php +++ b/src/wp-includes/class-wp-theme-json-data.php @@ -72,9 +72,9 @@ public function get_data() { /** * Return theme JSON object. - * + * * @since 6.6.0 - * + * * @return WP_Theme_JSON */ public function get_theme_json() { From bbcc411749722968ab19f2860587f1353df750a2 Mon Sep 17 00:00:00 2001 From: Karthik Thayyil Date: Tue, 30 Apr 2024 17:43:04 +0100 Subject: [PATCH 3/4] remove cyclic WP_Theme_JSON call --- src/wp-includes/class-wp-theme-json-resolver.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/class-wp-theme-json-resolver.php b/src/wp-includes/class-wp-theme-json-resolver.php index 6e83d990eca8a..59c5f54b96e45 100644 --- a/src/wp-includes/class-wp-theme-json-resolver.php +++ b/src/wp-includes/class-wp-theme-json-resolver.php @@ -173,8 +173,7 @@ public static function get_core_data() { * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. */ $theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) ); - $config = $theme_json->get_data(); - static::$core = new WP_Theme_JSON( $config, 'default' ); + static::$core = $theme_json->get_theme_json(); return static::$core; } @@ -386,9 +385,7 @@ public static function get_block_data() { * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. */ $theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) ); - $config = $theme_json->get_data(); - - static::$blocks = new WP_Theme_JSON( $config, 'blocks' ); + static::$blocks = $theme_json->get_theme_json(); return static::$blocks; } @@ -522,8 +519,7 @@ public static function get_user_data() { * @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data. */ $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); - $config = $theme_json->get_data(); - return new WP_Theme_JSON( $config, 'custom' ); + return $theme_json->get_theme_json(); } /* @@ -542,8 +538,7 @@ public static function get_user_data() { /** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */ $theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) ); - $config = $theme_json->get_data(); - static::$user = new WP_Theme_JSON( $config, 'custom' ); + static::$user = $theme_json->get_theme_json(); return static::$user; } From 002c2cc52623f8b1fb0aca20a7833ff969c3b19c Mon Sep 17 00:00:00 2001 From: Karthik Thayyil <30643833+kt-12@users.noreply.github.com> Date: Wed, 1 May 2024 09:55:26 +0100 Subject: [PATCH 4/4] Update src/wp-includes/class-wp-theme-json-data.php fix grammar Co-authored-by: Pascal Birchler --- src/wp-includes/class-wp-theme-json-data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php index fefa68206cb03..aa8cbd71b8de8 100644 --- a/src/wp-includes/class-wp-theme-json-data.php +++ b/src/wp-includes/class-wp-theme-json-data.php @@ -71,7 +71,7 @@ public function get_data() { } /** - * Return theme JSON object. + * Returns theme JSON object. * * @since 6.6.0 *