Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Retrieve registered style variations from blocks meta
  • Loading branch information
oandregal committed Apr 17, 2023
commit 459dcce75768636669a232403c964f3f2a195aad
16 changes: 13 additions & 3 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,13 @@ public function __construct( $theme_json = array(), $origin = 'theme' ) {
$registry = WP_Block_Type_Registry::get_instance();
$valid_block_names = array_keys( $registry->get_all_registered() );
$valid_element_names = array_keys( static::ELEMENTS );
$valid_variations = array(
'core/quote' => array( 'plain' ),
);
$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'] );
}
$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 );

Expand Down Expand Up @@ -2833,6 +2837,12 @@ public static function remove_insecure_properties( $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'] );
}

$theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names, $valid_variations );

Expand Down