Make WordPress Core


Ignore:
Timestamp:
04/09/2024 07:18:41 AM (8 months ago)
Author:
isabel_brison
Message:

Editor: skip outputting base layout rules if content and wide size values don’t exist.

Skip outputting layout rules that reference content and wide sizes CSS variables, if no layout sizes exist in the current theme.json.

Props andrewserong.
Fixes #60936.

File:
1 edited

Legend:

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

    r57885 r57948  
    13891389     * @since 6.1.0
    13901390     * @since 6.3.0 Reduced specificity for layout margin rules.
     1391     * @since 6.5.1 Only output rules referencing content and wide sizes when values exist.
    13911392     *
    13921393     * @param array $block_metadata Metadata about the block to get styles for.
     
    15491550                        ) {
    15501551                            foreach ( $base_style_rule['rules'] as $css_property => $css_value ) {
     1552                                // Skip rules that reference content size or wide size if they are not defined in the theme.json.
     1553                                if (
     1554                                    is_string( $css_value ) &&
     1555                                    ( str_contains( $css_value, '--global--content-size' ) || str_contains( $css_value, '--global--wide-size' ) ) &&
     1556                                    ! isset( $this->theme_json['settings']['layout']['contentSize'] ) &&
     1557                                    ! isset( $this->theme_json['settings']['layout']['wideSize'] )
     1558                                ) {
     1559                                    continue;
     1560                                }
     1561
    15511562                                if ( static::is_safe_css_declaration( $css_property, $css_value ) ) {
    15521563                                    $declarations[] = array(
Note: See TracChangeset for help on using the changeset viewer.