Skip to content

Commit

Permalink
Remove additional call to WP_Theme_JSON_Gutenberg::__construct (#61262
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kt-12 authored May 22, 2024
1 parent 528edb0 commit 51775a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 11 additions & 0 deletions lib/class-wp-theme-json-data-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,15 @@ public function update_with( $new_data ) {
public function get_data() {
return $this->theme_json->get_raw_data();
}

/**
* Return theme JSON object.
*
* @since 18.3.0
*
* @return WP_Theme_JSON
*/
public function get_theme_json() {
return $this->theme_json;
}
}
17 changes: 7 additions & 10 deletions lib/class-wp-theme-json-resolver-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ public static function get_core_data() {
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
*/
$theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data_Gutenberg( $config, 'default' ) );
$config = $theme_json->get_data();
static::$core = new WP_Theme_JSON_Gutenberg( $config, 'default' );
static::$core = $theme_json->get_theme_json();

return static::$core;
}
Expand Down Expand Up @@ -254,9 +253,8 @@ public static function get_theme_data( $deprecated = array(), $options = array()
*
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
*/
$theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data_Gutenberg( $theme_json_data, 'theme' ) );
$theme_json_data = $theme_json->get_data();
static::$theme = new WP_Theme_JSON_Gutenberg( $theme_json_data );
$theme_json = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data_Gutenberg( $theme_json_data, 'theme' ) );
static::$theme = $theme_json->get_theme_json();

if ( $wp_theme->parent() ) {
// Get parent theme.json.
Expand Down Expand Up @@ -398,10 +396,9 @@ public static function get_block_data() {
*
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
*/
$theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data_Gutenberg( $config, 'blocks' ) );
$config = $theme_json->get_data();
$theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data_Gutenberg( $config, 'blocks' ) );
static::$blocks = $theme_json->get_theme_json();

static::$blocks = new WP_Theme_JSON_Gutenberg( $config, 'blocks' );
return static::$blocks;
}

Expand Down Expand Up @@ -533,8 +530,8 @@ public static function get_user_data() {
* @param WP_Theme_JSON_Data_Gutenberg Class to access and update the underlying data.
*/
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data_Gutenberg( $config, 'custom' ) );
$config = $theme_json->get_data();
return new WP_Theme_JSON_Gutenberg( $config, 'custom' );

return $theme_json->get_theme_json();
}

// Very important to verify that the flag isGlobalStylesUserThemeJSON is true.
Expand Down

1 comment on commit 51775a1

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 51775a1.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9194197192
📝 Reported issues:

Please sign in to comment.