From f47c9dd14c467894fe87ff916be5619f0e29bb07 Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:43:38 +1100 Subject: [PATCH 1/2] Layout: backport fix to ensure blocks without layout support do not receive layout classnames --- src/wp-includes/block-supports/layout.php | 3 +++ tests/phpunit/tests/block-supports/layout.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/wp-includes/block-supports/layout.php b/src/wp-includes/block-supports/layout.php index 67d6a3f1b77ac..4da4f24b23be9 100644 --- a/src/wp-includes/block-supports/layout.php +++ b/src/wp-includes/block-supports/layout.php @@ -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(); diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index 379c10fe2b566..c082771c783fb 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -250,6 +250,25 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { ), 'expected_output' => '
A paragraph
', + 'block' => array( + 'blockName' => 'core/paragraph', + 'attrs' => array( + 'style' => array( + 'layout' => array( + 'selfStretch' => 'fit' + ) + ), + ), + 'innerBlocks' => array(), + 'innerHTML' => 'A paragraph
', + 'innerContent' => array( 'A paragraph
' ), + ), + ), + 'expected_output' => 'A paragraph
', + ) ); } From 9abfc257f2f30958a103410d4677d78de08011cb Mon Sep 17 00:00:00 2001 From: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Date: Fri, 19 Jan 2024 12:51:23 +1100 Subject: [PATCH 2/2] Fix linting issues, add ticket number --- tests/phpunit/tests/block-supports/layout.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index c082771c783fb..a5f67f50f9b11 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -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 * @@ -258,8 +259,8 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { 'attrs' => array( 'style' => array( 'layout' => array( - 'selfStretch' => 'fit' - ) + 'selfStretch' => 'fit', + ), ), ), 'innerBlocks' => array(), @@ -268,7 +269,7 @@ public function data_layout_support_flag_renders_classnames_on_wrapper() { ), ), 'expected_output' => 'A paragraph
', - ) + ), ); }