Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout: backport fix to ensure blocks without layout support do not receive layout classnames #5900

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/wp-includes/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ function wp_render_layout_support_flag( $block_content, $block ) {
$processor->add_class( $class_name );
}
return $processor->get_updated_html();
} elseif ( ! $block_supports_layout ) {
// Ensure layout classnames are not injected if there is no layout support.
return $block_content;
}

$global_settings = wp_get_global_settings();
Expand Down
20 changes: 20 additions & 0 deletions tests/phpunit/tests/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public function test_outer_container_not_restored_for_aligned_image_block_with_t
/**
* @ticket 57584
* @ticket 58548
* @ticket 60292
*
* @dataProvider data_layout_support_flag_renders_classnames_on_wrapper
*
Expand Down Expand Up @@ -250,6 +251,25 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() {
),
'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>',
),
'skip classname output if block does not support layout and there are no child layout classes to be output' => array(
'args' => array(
'block_content' => '<p>A paragraph</p>',
'block' => array(
'blockName' => 'core/paragraph',
'attrs' => array(
'style' => array(
'layout' => array(
'selfStretch' => 'fit',
),
),
),
'innerBlocks' => array(),
'innerHTML' => '<p>A paragraph</p>',
'innerContent' => array( '<p>A paragraph</p>' ),
),
),
'expected_output' => '<p>A paragraph</p>',
),
);
}

Expand Down
Loading