mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Editor: Improve compatibility for WP_Theme_JSON_Data
.
This checks that objects returned from any of the `wp_theme_json_data_` filters are `WP_Theme_JSON_Data` objects in order to avoid incompatibilities. Otherwise, reprocess the theme.json data as new `WP_Theme_JSON` objects to ensure the data matches the expectations of code consuming that data. Follow-up to [58185]. Props joemcgill, adamsilverstein, oandregal, ryelle, ocean90, pbearne. See #61112. Built from https://develop.svn.wordpress.org/trunk@58443 git-svn-id: http://core.svn.wordpress.org/trunk@57892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
dd55b026a8
commit
b9096d9c7f
@ -172,8 +172,18 @@ class WP_Theme_JSON_Resolver {
|
|||||||
*
|
*
|
||||||
* @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying 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' ) );
|
$theme_json = apply_filters( 'wp_theme_json_data_default', new WP_Theme_JSON_Data( $config, 'default' ) );
|
||||||
static::$core = $theme_json->get_theme_json();
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
|
||||||
|
* compatible class that is not a WP_Theme_JSON_Data object.
|
||||||
|
*/
|
||||||
|
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
|
||||||
|
static::$core = $theme_json->get_theme_json();
|
||||||
|
} else {
|
||||||
|
$config = $theme_json->get_data();
|
||||||
|
static::$core = new WP_Theme_JSON( $config, 'default' );
|
||||||
|
}
|
||||||
|
|
||||||
return static::$core;
|
return static::$core;
|
||||||
}
|
}
|
||||||
@ -263,8 +273,18 @@ class WP_Theme_JSON_Resolver {
|
|||||||
*
|
*
|
||||||
* @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying data.
|
* @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 = apply_filters( 'wp_theme_json_data_theme', new WP_Theme_JSON_Data( $theme_json_data, 'theme' ) );
|
||||||
static::$theme = $theme_json->get_theme_json();
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
|
||||||
|
* compatible class that is not a WP_Theme_JSON_Data object.
|
||||||
|
*/
|
||||||
|
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
|
||||||
|
static::$theme = $theme_json->get_theme_json();
|
||||||
|
} else {
|
||||||
|
$config = $theme_json->get_data();
|
||||||
|
static::$theme = new WP_Theme_JSON( $config );
|
||||||
|
}
|
||||||
|
|
||||||
if ( $wp_theme->parent() ) {
|
if ( $wp_theme->parent() ) {
|
||||||
// Get parent theme.json.
|
// Get parent theme.json.
|
||||||
@ -386,8 +406,19 @@ class WP_Theme_JSON_Resolver {
|
|||||||
*
|
*
|
||||||
* @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying 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' ) );
|
$theme_json = apply_filters( 'wp_theme_json_data_blocks', new WP_Theme_JSON_Data( $config, 'blocks' ) );
|
||||||
static::$blocks = $theme_json->get_theme_json();
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
|
||||||
|
* compatible class that is not a WP_Theme_JSON_Data object.
|
||||||
|
*/
|
||||||
|
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
|
||||||
|
static::$blocks = $theme_json->get_theme_json();
|
||||||
|
} else {
|
||||||
|
$config = $theme_json->get_data();
|
||||||
|
static::$blocks = new WP_Theme_JSON( $config, 'blocks' );
|
||||||
|
}
|
||||||
|
|
||||||
return static::$blocks;
|
return static::$blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +554,17 @@ class WP_Theme_JSON_Resolver {
|
|||||||
* @param WP_Theme_JSON_Data $theme_json Class to access and update the underlying 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' ) );
|
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
|
||||||
return $theme_json->get_theme_json();
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
|
||||||
|
* compatible class that is not a WP_Theme_JSON_Data object.
|
||||||
|
*/
|
||||||
|
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
|
||||||
|
return $theme_json->get_theme_json();
|
||||||
|
} else {
|
||||||
|
$config = $theme_json->get_data();
|
||||||
|
return new WP_Theme_JSON( $config, 'custom' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -545,8 +586,18 @@ class WP_Theme_JSON_Resolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/class-wp-theme-json-resolver.php */
|
/** 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' ) );
|
$theme_json = apply_filters( 'wp_theme_json_data_user', new WP_Theme_JSON_Data( $config, 'custom' ) );
|
||||||
static::$user = $theme_json->get_theme_json();
|
|
||||||
|
/*
|
||||||
|
* Backward compatibility for extenders returning a WP_Theme_JSON_Data
|
||||||
|
* compatible class that is not a WP_Theme_JSON_Data object.
|
||||||
|
*/
|
||||||
|
if ( $theme_json instanceof WP_Theme_JSON_Data ) {
|
||||||
|
static::$user = $theme_json->get_theme_json();
|
||||||
|
} else {
|
||||||
|
$config = $theme_json->get_data();
|
||||||
|
static::$user = new WP_Theme_JSON( $config, 'custom' );
|
||||||
|
}
|
||||||
|
|
||||||
return static::$user;
|
return static::$user;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.6-beta3-58442';
|
$wp_version = '6.6-beta3-58443';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user