Theme JSON: Extract util to get valid block style variations.
Extracts the repeated collection of valid block style variations into a util that can be reused or updated in a single place for future work around extending block style variations. Backports https://github.com/WordPress/gutenberg/pull/61030. Props aaronrobertshaw, audrasjb. Fixes #61121. Built from https://develop.svn.wordpress.org/trunk@58228 git-svn-id: http://core.svn.wordpress.org/trunk@57691 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
780d126082
commit
6a2b736c2f
|
@ -731,13 +731,7 @@ class WP_Theme_JSON {
|
|||
$this->theme_json = WP_Theme_JSON_Schema::migrate( $theme_json );
|
||||
$valid_block_names = array_keys( static::get_blocks_metadata() );
|
||||
$valid_element_names = array_keys( static::ELEMENTS );
|
||||
$valid_variations = array();
|
||||
foreach ( self::get_blocks_metadata() as $block_name => $block_meta ) {
|
||||
if ( ! isset( $block_meta['styleVariations'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$valid_variations[ $block_name ] = array_keys( $block_meta['styleVariations'] );
|
||||
}
|
||||
$valid_variations = static::get_valid_block_style_variations();
|
||||
$theme_json = static::sanitize( $this->theme_json, $valid_block_names, $valid_element_names, $valid_variations );
|
||||
$this->theme_json = static::maybe_opt_in_into_settings( $theme_json );
|
||||
|
||||
|
@ -3077,13 +3071,7 @@ class WP_Theme_JSON {
|
|||
|
||||
$valid_block_names = array_keys( static::get_blocks_metadata() );
|
||||
$valid_element_names = array_keys( static::ELEMENTS );
|
||||
$valid_variations = array();
|
||||
foreach ( self::get_blocks_metadata() as $block_name => $block_meta ) {
|
||||
if ( ! isset( $block_meta['styleVariations'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$valid_variations[ $block_name ] = array_keys( $block_meta['styleVariations'] );
|
||||
}
|
||||
$valid_variations = static::get_valid_block_style_variations();
|
||||
|
||||
$theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names, $valid_variations );
|
||||
|
||||
|
@ -4032,4 +4020,23 @@ class WP_Theme_JSON {
|
|||
|
||||
return implode( ',', $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects valid block style variations keyed by block type.
|
||||
*
|
||||
* @since 6.6.0
|
||||
*
|
||||
* @return array Valid block style variations by block type.
|
||||
*/
|
||||
protected static function get_valid_block_style_variations() {
|
||||
$valid_variations = array();
|
||||
foreach ( self::get_blocks_metadata() as $block_name => $block_meta ) {
|
||||
if ( ! isset( $block_meta['styleVariations'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$valid_variations[ $block_name ] = array_keys( $block_meta['styleVariations'] );
|
||||
}
|
||||
|
||||
return $valid_variations;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-alpha-58227';
|
||||
$wp_version = '6.6-alpha-58228';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue