Make WordPress Core


Ignore:
Timestamp:
04/05/2022 12:06:48 PM (5 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/spacing.php

    r52434 r53076  
    4545 */
    4646function wp_apply_spacing_support( $block_type, $block_attributes ) {
    47         if ( wp_skip_spacing_serialization( $block_type ) ) {
     47        if ( wp_should_skip_block_supports_serialization( $block_type, 'spacing' ) ) {
    4848                return array();
    4949        }
    … …  
    5151        $has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
    5252        $has_margin_support  = block_has_support( $block_type, array( 'spacing', 'margin' ), false );
     53        $skip_padding        = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'padding' );
     54        $skip_margin         = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'margin' );
    5355        $styles              = array();
    5456
    55         if ( $has_padding_support ) {
     57        if ( $has_padding_support && ! $skip_padding ) {
    5658                $padding_value = _wp_array_get( $block_attributes, array( 'style', 'spacing', 'padding' ), null );
    5759                if ( is_array( $padding_value ) ) {
    … …  
    6466        }
    6567
    66         if ( $has_margin_support ) {
     68        if ( $has_margin_support && ! $skip_margin ) {
    6769                $margin_value = _wp_array_get( $block_attributes, array( 'style', 'spacing', 'margin' ), null );
    6870                if ( is_array( $margin_value ) ) {
    … …  
    7880}
    7981
    80 /**
    81  * Checks whether serialization of the current block's spacing properties should
    82  * occur.
    83  *
    84  * @since 5.9.0
    85  * @access private
    86  *
    87  * @param WP_Block_Type $block_type Block type.
    88  * @return bool Whether to serialize spacing support styles & classes.
    89  */
    90 function wp_skip_spacing_serialization( $block_type ) {
    91         $spacing_support = _wp_array_get( $block_type->supports, array( 'spacing' ), false );
    92 
    93         return is_array( $spacing_support ) &&
    94                 array_key_exists( '__experimentalSkipSerialization', $spacing_support ) &&
    95                 $spacing_support['__experimentalSkipSerialization'];
    96 }
    97 
    9882// Register the block support.
    9983WP_Block_Supports::get_instance()->register(
Note: See TracChangeset for help on using the changeset viewer.