diff --git a/src/wp-includes/class-wp-theme-json-data.php b/src/wp-includes/class-wp-theme-json-data.php index 6aa8a3971c62d..aa8cbd71b8de8 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(); } + + /** + * Returns 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 3ad5ecf0c4dde..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; } @@ -255,8 +254,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. @@ -387,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; } @@ -523,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(); } /* @@ -543,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; }