Make WordPress Core

Changeset 61619

Timestamp:
02/12/2026 05:06:08 AM (3 weeks ago)
Author:
ramonopoly
Message:

Block Supports: Add width to dimensions supports

This PR introduces dimensions.width to the list of available block supports.

This block support enables, in the future, the removal of the custom width and height controls in blocks such as Button, Column and many others in favor of customizations via block supports.

Props aaronrobertshaw, andrewserong, ramonopoly, welcher, mamaduka, wildworks, youknowriad, isabel_brison.

Fixes #64200.

Location:
trunk
Files:
5 edited

Legend:

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

    r61430 r61619  
    5252 */
    5353function wp_apply_dimensions_support( $block_type, $block_attributes ) {
     54
     55
    5456    if ( wp_should_skip_block_supports_serialization( $block_type, 'dimensions' ) ) {
    55         return array();
     57        return ;
    5658    }
    5759
    58     $attributes = array();
    59 
    60     // Width support to be added in near future.
    61 
    62     $has_min_height_support = block_has_support( $block_type, array( 'dimensions', 'minHeight' ), false );
    63     $block_styles           = $block_attributes['style'] ?? null;
     60    $block_styles = $block_attributes['style'] ?? null;
    6461
    6562    if ( ! $block_styles ) {
     
    6764    }
    6865
    69     $skip_min_height                      = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', 'minHeight' );
    70     $dimensions_block_styles              = array();
    71     $dimensions_block_styles['minHeight'] = null;
    72     if ( $has_min_height_support && ! $skip_min_height ) {
    73         $dimensions_block_styles['minHeight'] = $block_styles['dimensions']['minHeight'] ?? null;
     66    $dimensions_block_styles = array();
     67    $supported_features      = array( 'minHeight', 'width' );
     68
     69    foreach ( $supported_features as $feature ) {
     70        $has_support        = block_has_support( $block_type, array( 'dimensions', $feature ), false );
     71        $skip_serialization = wp_should_skip_block_supports_serialization( $block_type, 'dimensions', $feature );
     72
     73        $dimensions_block_styles[ $feature ] = null;
     74
     75        if ( $has_support && ! $skip_serialization ) {
     76            $dimensions_block_styles[ $feature ] = $block_styles['dimensions'][ $feature ] ?? null;
     77        }
    7478    }
     79
    7580    $styles = wp_style_engine_get_styles( array( 'dimensions' => $dimensions_block_styles ) );
    7681
  • trunk/src/wp-includes/class-wp-theme-json.php

    r61618 r61619  
    238238     * @since 6.6.0 Added `background-[image|position|repeat|size]` properties.
    239239     * @since 6.7.0 Added `background-attachment` property.
     240
    240241     * @var array
    241242     */
     
    302303        'filter'                            => array( 'filter', 'duotone' ),
    303304        'box-shadow'                        => array( 'shadow' ),
     305
    304306        'writing-mode'                      => array( 'typography', 'writingMode' ),
    305307    );
     
    397399     * @since 6.9.0 Added support for `border.radiusSizes`.
    398400     * @since 7.0.0 Added type markers to the schema for boolean values.
     401
    399402     * @var array
    400403     */
     
    436439            'defaultAspectRatios' => null,
    437440            'minHeight'           => null,
     441
    438442        ),
    439443        'layout'                        => array(
     
    529533     * @since 6.5.0 Added support for `dimensions.aspectRatio`.
    530534     * @since 6.6.0 Added `background` sub properties to top-level only.
     535
    531536     * @var array
    532537     */
     
    557562            'aspectRatio' => null,
    558563            'minHeight'   => null,
     564
    559565        ),
    560566        'filter'     => array(
     
    656662     *
    657663     * @since 6.1.0
     664
    658665     * @var string[]
    659666     */
     
    661668        '__experimentalBorder' => 'border',
    662669        'color'                => 'color',
     670
    663671        'spacing'              => 'spacing',
    664672        'typography'           => 'typography',
     
    765773     * @since 6.4.0 Added `background.backgroundImage`.
    766774     * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`.
     775
    767776     * @var array
    768777     */
     
    780789        array( 'dimensions', 'aspectRatio' ),
    781790        array( 'dimensions', 'minHeight' ),
     791
    782792        array( 'position', 'sticky' ),
    783793        array( 'spacing', 'blockGap' ),
  • trunk/src/wp-includes/style-engine/class-wp-style-engine.php

    r60892 r61619  
    220220                ),
    221221            ),
     222
     223
     224
     225
     226
     227
    222228        ),
    223229        'spacing'    => array(
  • trunk/tests/phpunit/tests/block-supports/wpApplyDimensionsSupport.php

    r55175 r61619  
    101101        );
    102102    }
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
    103174}
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r61618 r61619  
    282282                'aspectRatio' => true,
    283283                'minHeight'   => true,
     284
    284285            ),
    285286            'position'   => array(
     
    321322                        'aspectRatio' => true,
    322323                        'minHeight'   => true,
     324
    323325                    ),
    324326                    'position'   => array(
Note: See TracChangeset for help on using the changeset viewer.