Make WordPress Core

Changeset 58057

Timestamp:
04/30/2024 03:17:43 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.
Reviewed by jorbin.
Merges [58028] to the 6.5 branch.
See #60981.

Location:
branches/6.5
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.5

  • branches/6.5/src/wp-includes/class-wp-theme-json.php

    r58056 r58057  
    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 );
    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
    13921393     *
    13931394     * @param array $block_metadata Metadata about the block to get styles for.
     1395
    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 ) {
    13971399        $block_rules = '';
    13981400        $block_type  = null;
     
    15431545                    foreach ( $base_style_rules as $base_style_rule ) {
    15441546                        $declarations = array();
     1547
     1548
     1549
     1550
     1551
    15451552
    15461553                        if (
  • branches/6.5/tests/phpunit/tests/theme/wpThemeJson.php

    r58056 r58057  
    12611261        // Note the `base-layout-styles` includes a fallback gap for the Columns block for backwards compatibility.
    12621262        $this->assertSame(
    1263             ':where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flow > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}body .is-layout-flow > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}body .is-layout-flow > .aligncenter{margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}body .is-layout-constrained > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}body .is-layout-constrained > .aligncenter{margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)){max-width: var(--wp--style--global--content-size);margin-left: auto !important;margin-right: auto !important;}body .is-layout-constrained > .alignwide{max-width: var(--wp--style--global--wide-size);}body .is-layout-flex{display: flex;}body .is-layout-flex{flex-wrap: wrap;align-items: center;}body .is-layout-flex > *{margin: 0;}body .is-layout-grid{display: grid;}body .is-layout-grid > *{margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}',
     1263            ':where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}body .is-layout-flex{display: flex;}body .is-layout-flex{flex-wrap: wrap;align-items: center;}body .is-layout-flex > *{margin: 0;}body .is-layout-grid{display: grid;}body .is-layout-grid > *{margin: 0;}:where(.wp-block-columns.is-layout-flex){gap: 2em;}:where(.wp-block-columns.is-layout-grid){gap: 2em;}:where(.wp-block-post-template.is-layout-flex){gap: 1.25em;}:where(.wp-block-post-template.is-layout-grid){gap: 1.25em;}',
    12641264            $stylesheet
    12651265        );
Note: See TracChangeset for help on using the changeset viewer.