Make WordPress Core


Ignore:
Timestamp:
04/13/2021 08:02:33 AM (4 years ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r50629 r50703  
    23042304    foreach ( $block_styles as $block_name => $styles ) {
    23052305        foreach ( $styles as $style_properties ) {
     2306            $block_style = array(
     2307                'name'  => $style_properties['name'],
     2308                'label' => $style_properties['label'],
     2309            );
     2310            if ( isset( $style_properties['is_default'] ) ) {
     2311                $block_style['isDefault'] = $style_properties['is_default'];
     2312            }
    23062313            $register_script_lines[] = sprintf(
    23072314                '   wp.blocks.registerBlockStyle( \'%s\', %s );',
    23082315                $block_name,
    2309                 wp_json_encode(
    2310                     array(
    2311                         'name'  => $style_properties['name'],
    2312                         'label' => $style_properties['label'],
    2313                     )
    2314                 )
     2316                wp_json_encode( $block_style )
    23152317            );
    23162318        }
Note: See TracChangeset for help on using the changeset viewer.