Make WordPress Core


Ignore:
Timestamp:
04/05/2022 12:06:48 PM (3 years ago)
Author:
gziolo
Message:

Editor: Backport block support changes from the Gutenberg plugin

Migrate spacing, border, color, dimensions, elements and typography and associated tests for block supports in the block editor.

Related changes in Gutenberg:

Props ramonopoly, aaronrobertshaw.
See #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-supports/border.php

    r52302 r53076  
    5151 */
    5252function wp_apply_border_support( $block_type, $block_attributes ) {
    53     if ( wp_skip_border_serialization( $block_type ) ) {
     53    if ( wp_should_skip_block_supports_serialization( $block_type, 'border' ) ) {
    5454        return array();
    5555    }
     
    6161    if (
    6262        wp_has_border_feature_support( $block_type, 'radius' ) &&
    63         isset( $block_attributes['style']['border']['radius'] )
     63        isset( $block_attributes['style']['border']['radius'] ) &&
     64        ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'radius' )
    6465    ) {
    6566        $border_radius = $block_attributes['style']['border']['radius'];
     
    8586    if (
    8687        wp_has_border_feature_support( $block_type, 'style' ) &&
    87         isset( $block_attributes['style']['border']['style'] )
     88        isset( $block_attributes['style']['border']['style'] ) &&
     89        ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'style' )
    8890    ) {
    8991        $border_style = $block_attributes['style']['border']['style'];
     
    9496    if (
    9597        wp_has_border_feature_support( $block_type, 'width' ) &&
    96         isset( $block_attributes['style']['border']['width'] )
     98        isset( $block_attributes['style']['border']['width'] ) &&
     99        ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' )
    97100    ) {
    98101        $border_width = $block_attributes['style']['border']['width'];
     
    107110
    108111    // Border color.
    109     if ( wp_has_border_feature_support( $block_type, 'color' ) ) {
     112    if (
     113        wp_has_border_feature_support( $block_type, 'color' ) &&
     114        ! wp_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'color' )
     115    ) {
    110116        $has_named_border_color  = array_key_exists( 'borderColor', $block_attributes );
    111117        $has_custom_border_color = isset( $block_attributes['style']['border']['color'] );
     
    135141
    136142    return $attributes;
    137 }
    138 
    139 /**
    140  * Checks whether serialization of the current block's border properties should
    141  * occur.
    142  *
    143  * @since 5.8.0
    144  * @access private
    145  *
    146  * @param WP_Block_Type $block_type Block type.
    147  * @return bool Whether serialization of the current block's border properties
    148  *              should occur.
    149  */
    150 function wp_skip_border_serialization( $block_type ) {
    151     $border_support = _wp_array_get( $block_type->supports, array( '__experimentalBorder' ), false );
    152 
    153     return is_array( $border_support ) &&
    154         array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
    155         $border_support['__experimentalSkipSerialization'];
    156143}
    157144
Note: See TracChangeset for help on using the changeset viewer.