Make WordPress Core

Changeset 57328


Ignore:
Timestamp:
01/23/2024 05:36:40 AM (8 months ago)
Author:
isabel_brison
Message:

Editor: fix classname output on blocks without layout.

Prevents layout classnames from being output on blocks with no layout support and no child layout classnames by returning early from wp_render_layout_support_flag.

Props andrewserong.
Fixes #60292.

Location:
trunk
Files:
2 edited

Legend:

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

    r57246 r57328  
    616616        }
    617617        return $processor->get_updated_html();
     618    } elseif ( ! $block_supports_layout ) {
     619        // Ensure layout classnames are not injected if there is no layout support.
     620        return $block_content;
    618621    }
    619622
  • trunk/tests/phpunit/tests/block-supports/layout.php

    r57246 r57328  
    172172     * @ticket 57584
    173173     * @ticket 58548
     174     * @ticket 60292
    174175     *
    175176     * @dataProvider data_layout_support_flag_renders_classnames_on_wrapper
     
    251252                'expected_output' => '<div class="wp-block-group"><div class="wp-block-group__inner-wrapper is-layout-flow wp-block-group-is-layout-flow"></div></div>',
    252253            ),
     254            'skip classname output if block does not support layout and there are no child layout classes to be output' => array(
     255                'args'            => array(
     256                    'block_content' => '<p>A paragraph</p>',
     257                    'block'         => array(
     258                        'blockName'    => 'core/paragraph',
     259                        'attrs'        => array(
     260                            'style' => array(
     261                                'layout' => array(
     262                                    'selfStretch' => 'fit',
     263                                ),
     264                            ),
     265                        ),
     266                        'innerBlocks'  => array(),
     267                        'innerHTML'    => '<p>A paragraph</p>',
     268                        'innerContent' => array( '<p>A paragraph</p>' ),
     269                    ),
     270                ),
     271                'expected_output' => '<p>A paragraph</p>',
     272            ),
    253273        );
    254274    }
Note: See TracChangeset for help on using the changeset viewer.