Make WordPress Core


Ignore:
Timestamp:
04/22/2024 05:28:50 AM (3 months ago)
Author:
isabel_brison
Message:

Editor: limit layout rules on themes without theme.json.

Removes output of base rules for flow and constrained layout types on themes without theme.json.

Props evanltd, poena, isabel_brison, andrewserong, oandregal.
See #60981.

File:
1 edited

Legend:

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

    r57987 r58028  
    12281228
    12291229            foreach ( $base_styles_nodes as $base_style_node ) {
    1230                 $stylesheet .= $this->get_layout_styles( $base_style_node );
     1230                $stylesheet .= $this->get_layout_styles( $base_style_node, $types );
    12311231            }
    12321232        }
     
    13901390     * @since 6.3.0 Reduced specificity for layout margin rules.
    13911391     * @since 6.5.1 Only output rules referencing content and wide sizes when values exist.
     1392     * @since 6.5.3 Add types parameter to check if only base layout styles are needed.
    13921393     *
    13931394     * @param array $block_metadata Metadata about the block to get styles for.
     1395     * @param array $types Optional. Types of styles to output. If empty, all styles will be output.
    13941396     * @return string Layout styles for the block.
    13951397     */
    1396     protected function get_layout_styles( $block_metadata ) {
     1398    protected function get_layout_styles( $block_metadata, $types = array() ) {
    13971399        $block_rules = '';
    13981400        $block_type  = null;
     
    15431545                    foreach ( $base_style_rules as $base_style_rule ) {
    15441546                        $declarations = array();
     1547
     1548                        // Skip outputting base styles for flow and constrained layout types if theme doesn't support theme.json. The 'base-layout-styles' type flags this.
     1549                        if ( in_array( 'base-layout-styles', $types, true ) && ( 'default' === $layout_definition['name'] || 'constrained' === $layout_definition['name'] ) ) {
     1550                            continue;
     1551                        }
    15451552
    15461553                        if (
Note: See TracChangeset for help on using the changeset viewer.