Make WordPress Core


Ignore:
Timestamp:
01/31/2024 02:52:25 AM (12 months ago)
Author:
isabel_brison
Message:

Editor: introduce dimensions.aspectRatio block support.

Adds front end rendering logic for the dimensions.aspectRatio block support as well as the required logic in WP_Theme_JSON and the style engine.

Props andrewserong.
Fixes #60365.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r57490 r57491  
    205205     * @since 6.3.0 Added `column-count` property.
    206206     * @since 6.4.0 Added `writing-mode` property.
     207     * @since 6.5.0 Added `aspect-ratio` property.
    207208     *
    208209     * @var array
    209210     */
    210211    const PROPERTIES_METADATA = array(
     212        'aspect-ratio'                      => array( 'dimensions', 'aspectRatio' ),
    211213        'background'                        => array( 'color', 'gradient' ),
    212214        'background-color'                  => array( 'color', 'background' ),
     
    345347     * @since 6.4.0 Added support for `layout.allowEditing`, `background.backgroundImage`,
    346348     *              `typography.writingMode`, `lightbox.enabled` and `lightbox.allowEditing`.
    347      * @since 6.5.0 Added support for `layout.allowCustomContentAndWideSize` and
    348      *              `background.backgroundSize`.
     349     * @since 6.5.0 Added support for `layout.allowCustomContentAndWideSize`,
     350     *              `background.backgroundSize` and `dimensions.aspectRatio`.
    349351     * @var array
    350352     */
     
    381383        'custom'                        => null,
    382384        'dimensions'                    => array(
    383             'minHeight' => null,
     385            'aspectRatio' => null,
     386            'minHeight'   => null,
    384387        ),
    385388        'layout'                        => array(
     
    439442     * @since 6.2.0 Added `outline`, and `minHeight` properties.
    440443     * @since 6.3.0 Added support for `typography.textColumns`.
     444     * @since 6.5.0 Added support for `dimensions.aspectRatio`.
    441445     *
    442446     * @var array
     
    459463        ),
    460464        'dimensions' => array(
    461             'minHeight' => null,
     465            'aspectRatio' => null,
     466            'minHeight'   => null,
    462467        ),
    463468        'filter'     => array(
     
    576581     * @since 6.2.0 Added `dimensions.minHeight` and `position.sticky`.
    577582     * @since 6.4.0 Added `background.backgroundImage`.
    578      * @since 6.5.0 Added `background.backgroundSize`.
     583     * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`.
    579584     * @var array
    580585     */
     
    590595        array( 'color', 'button' ),
    591596        array( 'color', 'caption' ),
     597        array( 'dimensions', 'aspectRatio' ),
    592598        array( 'dimensions', 'minHeight' ),
    593599        array( 'position', 'sticky' ),
     
    19221928     * @since 5.9.0 Added the `$settings` and `$properties` parameters.
    19231929     * @since 6.1.0 Added `$theme_json`, `$selector`, and `$use_root_padding` parameters.
     1930     * @since 6.5.0 Output a `min-height: unset` rule when `aspect-ratio` is set.
    19241931     *
    19251932     * @param array   $styles Styles to process.
     
    19911998                 */
    19921999                $value = wp_get_typography_font_size_value( array( 'size' => $value ) );
     2000            }
     2001
     2002            if ( 'aspect-ratio' === $css_property ) {
     2003                // For aspect ratio to work, other dimensions rules must be unset.
     2004                // This ensures that a fixed height does not override the aspect ratio.
     2005                $declarations[] = array(
     2006                    'name'  => 'min-height',
     2007                    'value' => 'unset',
     2008                );
    19932009            }
    19942010
Note: See TracChangeset for help on using the changeset viewer.