Make WordPress Core


Ignore:
Timestamp:
05/20/2022 03:49:09 PM (3 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages for 6.0 RC 4

[53419] Editor: Fix opinionated block styles loading in editor

[53420] Editor: Update WordPress packages for 6.0 RC 4

[53421] Docs: Add missing documentation for fallback_gap_value param

Props SergeyBiryukov, zieladam, jffng.
Merges [53419], [53420] and [53421] to the 6.0 branch.
Fixes #55567.

Location:
branches/6.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.0

  • branches/6.0/src/wp-includes/block-supports/layout.php

    r53085 r53422  
    4242 * @param string  $gap_value                     The block gap value to apply.
    4343 * @param boolean $should_skip_gap_serialization Whether to skip applying the user-defined value set in the editor.
     44 * @param string  $fallback_gap_value            The custom fallback value for block gap.
    4445 * @return string CSS style.
    4546 */
    46 function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false ) {
     47function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em' ) {
    4748    $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default';
    4849
     
    103104        if ( $has_block_gap_support ) {
    104105            if ( is_array( $gap_value ) ) {
    105                 $gap_row    = isset( $gap_value['top'] ) ? $gap_value['top'] : '0.5em';
    106                 $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em';
     106                $gap_row    = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap_value;
     107                $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap_value;
    107108                $gap_value  = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
    108109            }
    109             $gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';
     110            $gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : "var( --wp--style--block-gap, $fallback_gap_value )";
    110111            $style    .= "gap: $gap_style;";
    111112        } else {
    112             $style .= 'gap: 0.5em;';
     113            $style .= "gap: $fallback_gap_value;";
    113114        }
    114115
     
    183184    }
    184185
     186    $fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' );
     187
    185188    // If a block's block.json skips serialization for spacing or spacing.blockGap,
    186189    // don't apply the user-defined value to the styles.
    187190    $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' );
    188     $style                         = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization );
     191    $style                         = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value );
    189192    // This assumes the hook only applies to blocks with a single wrapper.
    190193    // I think this is a reasonable limitation for that particular hook.
Note: See TracChangeset for help on using the changeset viewer.