mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 04:34:31 +00:00
Blocks: Add is_default handling to server side block styles registry
Ensures that register_block_style lets developer pass `is_default` flag to mark one of the block style variations as the default one. Props mukesh27, xavivars. Fixes #53006. git-svn-id: https://develop.svn.wordpress.org/trunk@50703 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2303,15 +2303,17 @@ function enqueue_editor_block_styles_assets() {
|
||||
$register_script_lines = array( '( function() {' );
|
||||
foreach ( $block_styles as $block_name => $styles ) {
|
||||
foreach ( $styles as $style_properties ) {
|
||||
$block_style = array(
|
||||
'name' => $style_properties['name'],
|
||||
'label' => $style_properties['label'],
|
||||
);
|
||||
if ( isset( $style_properties['is_default'] ) ) {
|
||||
$block_style['isDefault'] = $style_properties['is_default'];
|
||||
}
|
||||
$register_script_lines[] = sprintf(
|
||||
' wp.blocks.registerBlockStyle( \'%s\', %s );',
|
||||
$block_name,
|
||||
wp_json_encode(
|
||||
array(
|
||||
'name' => $style_properties['name'],
|
||||
'label' => $style_properties['label'],
|
||||
)
|
||||
)
|
||||
wp_json_encode( $block_style )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user