From 63f81c1e9cbb3b0513abca2b8cb579fef374ed7b Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Tue, 3 Dec 2024 19:25:14 +0530 Subject: [PATCH 1/6] Image size fix in lightbox --- lib/block-supports/layout.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index ddbd1917c30547..ca75f479dd67b5 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -1106,15 +1106,14 @@ function gutenberg_restore_image_outer_container( $block_content, $block ) { $wrapper_classnames = array( 'wp-block-image' ); - // If the block has a classNames attribute these classnames need to be removed from the content and added back + // If the block has a classNames attribute these classnames need to be added back // to the new wrapper div also. if ( ! empty( $block['attrs']['className'] ) ) { $wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) ); } - $content_classnames = explode( ' ', $matches[2] ); - $filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames ); - return '
' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . '
'; + // Wrap the existing content with the new wrapper div. + return '
' . $block_content . '
'; } if ( function_exists( 'wp_restore_image_outer_container' ) ) { From 0e19583c619fda88a7db00352e2813357281f3ef Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Tue, 3 Dec 2024 19:56:00 +0530 Subject: [PATCH 2/6] Revert "Image size fix in lightbox" This reverts commit 63f81c1e9cbb3b0513abca2b8cb579fef374ed7b. --- lib/block-supports/layout.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index ca75f479dd67b5..ddbd1917c30547 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -1106,14 +1106,15 @@ function gutenberg_restore_image_outer_container( $block_content, $block ) { $wrapper_classnames = array( 'wp-block-image' ); - // If the block has a classNames attribute these classnames need to be added back + // If the block has a classNames attribute these classnames need to be removed from the content and added back // to the new wrapper div also. if ( ! empty( $block['attrs']['className'] ) ) { $wrapper_classnames = array_merge( $wrapper_classnames, explode( ' ', $block['attrs']['className'] ) ); } + $content_classnames = explode( ' ', $matches[2] ); + $filtered_content_classnames = array_diff( $content_classnames, $wrapper_classnames ); - // Wrap the existing content with the new wrapper div. - return '
' . $block_content . '
'; + return '
' . $matches[1] . implode( ' ', $filtered_content_classnames ) . $matches[3] . '
'; } if ( function_exists( 'wp_restore_image_outer_container' ) ) { From 12131dbee648dae1a4a95ddedd54bb3407d8f792 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Fri, 20 Dec 2024 19:33:20 +0530 Subject: [PATCH 3/6] Reverting Stabilization block support --- backport-changelog/6.8/7069.md | 1 - lib/compat/wordpress-6.8/blocks.php | 29 +++---- phpunit/block-supports/border-test.php | 100 ------------------------- 3 files changed, 12 insertions(+), 118 deletions(-) diff --git a/backport-changelog/6.8/7069.md b/backport-changelog/6.8/7069.md index 3e734637ddbb2f..69edbde58902d1 100644 --- a/backport-changelog/6.8/7069.md +++ b/backport-changelog/6.8/7069.md @@ -3,4 +3,3 @@ https://github.com/WordPress/wordpress-develop/pull/7069 * https://github.com/WordPress/gutenberg/pull/63401 * https://github.com/WordPress/gutenberg/pull/66918 * https://github.com/WordPress/gutenberg/pull/67018 -* https://github.com/WordPress/gutenberg/pull/67552 diff --git a/lib/compat/wordpress-6.8/blocks.php b/lib/compat/wordpress-6.8/blocks.php index dc8747c04aec2f..d1905c459d7531 100644 --- a/lib/compat/wordpress-6.8/blocks.php +++ b/lib/compat/wordpress-6.8/blocks.php @@ -71,10 +71,6 @@ function gutenberg_stabilize_experimental_block_supports( $args ) { } $stabilize_config = function ( $unstable_config, $stable_support_key ) use ( $experimental_support_properties, $common_experimental_properties ) { - if ( ! is_array( $unstable_config ) ) { - return $unstable_config; - } - $stable_config = array(); foreach ( $unstable_config as $key => $value ) { // Get stable key from support-specific map, common properties map, or keep original. @@ -120,19 +116,18 @@ function gutenberg_stabilize_experimental_block_supports( $args ) { ( $key_positions[ $support ] ?? PHP_INT_MAX ) < ( $key_positions[ $stable_support_key ] ?? PHP_INT_MAX ); - /* - * To merge the alternative support config effectively, it also needs to be - * stabilized before merging to keep stabilized and experimental flags in - * sync. - */ - $args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key ); - // Prevents reprocessing this support as it was stabilized above. - $done[ $stable_support_key ] = true; - - if ( is_array( $stable_config ) && is_array( $args['supports'][ $stable_support_key ] ) ) { - $stable_config = $experimental_first - ? array_merge( $stable_config, $args['supports'][ $stable_support_key ] ) - : array_merge( $args['supports'][ $stable_support_key ], $stable_config ); + if ( is_array( $args['supports'][ $stable_support_key ] ) ) { + /* + * To merge the alternative support config effectively, it also needs to be + * stabilized before merging to keep stabilized and experimental flags in + * sync. + */ + $args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key ); + $stable_config = $experimental_first + ? array_merge( $stable_config, $args['supports'][ $stable_support_key ] ) + : array_merge( $args['supports'][ $stable_support_key ], $stable_config ); + // Prevents reprocessing this support as it was merged above. + $done[ $stable_support_key ] = true; } else { $stable_config = $experimental_first ? $args['supports'][ $stable_support_key ] diff --git a/phpunit/block-supports/border-test.php b/phpunit/block-supports/border-test.php index 510633b48aab59..6ec43b369d9a2a 100644 --- a/phpunit/block-supports/border-test.php +++ b/phpunit/block-supports/border-test.php @@ -730,104 +730,4 @@ public function test_should_stabilize_border_supports_using_order_based_merge() ); $this->assertSame( $expected, $actual, 'Merged stabilized border block support config does not match when stable keys are first.' ); } - - /** - * Tests that boolean border support configurations are handled correctly. - * - * @dataProvider data_boolean_border_supports - * - * @param array $supports The supports configuration to test. - * @param boolean|array $expected_value The expected final border support value. - */ - public function test_should_handle_boolean_border_supports( $supports, $expected_value ) { - $args = array( - 'supports' => $supports, - ); - - $actual = gutenberg_stabilize_experimental_block_supports( $args ); - - $this->assertSame( $expected_value, $actual['supports']['border'] ); - } - - /** - * Data provider for boolean border support tests. - * - * @return array Test parameters. - */ - public function data_boolean_border_supports() { - return array( - 'experimental true only' => array( - array( - '__experimentalBorder' => true, - ), - true, - ), - 'experimental false only' => array( - array( - '__experimentalBorder' => false, - ), - false, - ), - 'experimental true before stable false' => array( - array( - '__experimentalBorder' => true, - 'border' => false, - ), - false, - ), - 'stable true before experimental false' => array( - array( - 'border' => true, - '__experimentalBorder' => false, - ), - false, - ), - 'experimental array before stable boolean' => array( - array( - '__experimentalBorder' => array( - 'color' => true, - 'width' => true, - ), - 'border' => false, - ), - false, - ), - 'stable array before experimental boolean' => array( - array( - 'border' => array( - 'color' => true, - 'width' => true, - ), - '__experimentalBorder' => true, - ), - true, - ), - 'experimental boolean before stable array' => array( - array( - '__experimentalBorder' => true, - 'border' => array( - 'color' => true, - 'width' => true, - ), - ), - array( - 'color' => true, - 'width' => true, - ), - ), - 'stable boolean before experimental array' => array( - array( - 'border' => false, - '__experimentalBorder' => array( - 'color' => true, - 'width' => true, - ), - ), - array( - 'color' => true, - 'width' => true, - ), - ), - ); - } } From 1f2e0ba4eccc44bb03ce8d0bbda45ee201a37f7a Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Fri, 20 Dec 2024 19:55:08 +0530 Subject: [PATCH 4/6] Intendation updates --- lib/compat/wordpress-6.8/blocks.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/compat/wordpress-6.8/blocks.php b/lib/compat/wordpress-6.8/blocks.php index d1905c459d7531..742f9d609d039e 100644 --- a/lib/compat/wordpress-6.8/blocks.php +++ b/lib/compat/wordpress-6.8/blocks.php @@ -116,18 +116,18 @@ function gutenberg_stabilize_experimental_block_supports( $args ) { ( $key_positions[ $support ] ?? PHP_INT_MAX ) < ( $key_positions[ $stable_support_key ] ?? PHP_INT_MAX ); - if ( is_array( $args['supports'][ $stable_support_key ] ) ) { - /* - * To merge the alternative support config effectively, it also needs to be - * stabilized before merging to keep stabilized and experimental flags in - * sync. - */ - $args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key ); - $stable_config = $experimental_first - ? array_merge( $stable_config, $args['supports'][ $stable_support_key ] ) - : array_merge( $args['supports'][ $stable_support_key ], $stable_config ); - // Prevents reprocessing this support as it was merged above. - $done[ $stable_support_key ] = true; + if ( is_array( $args['supports'][ $stable_support_key ] ) ) { + /* + * To merge the alternative support config effectively, it also needs to be + * stabilized before merging to keep stabilized and experimental flags in + * sync. + */ + $args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key ); + $stable_config = $experimental_first + ? array_merge( $stable_config, $args['supports'][ $stable_support_key ] ) + : array_merge( $args['supports'][ $stable_support_key ], $stable_config ); + // Prevents reprocessing this support as it was merged above. + $done[ $stable_support_key ] = true; } else { $stable_config = $experimental_first ? $args['supports'][ $stable_support_key ] From b307245be024876dba39ffde1aee1a21cb474f28 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Fri, 20 Dec 2024 19:57:38 +0530 Subject: [PATCH 5/6] Spacing issues --- lib/compat/wordpress-6.8/blocks.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/compat/wordpress-6.8/blocks.php b/lib/compat/wordpress-6.8/blocks.php index 742f9d609d039e..00761d148f4ac7 100644 --- a/lib/compat/wordpress-6.8/blocks.php +++ b/lib/compat/wordpress-6.8/blocks.php @@ -118,10 +118,10 @@ function gutenberg_stabilize_experimental_block_supports( $args ) { if ( is_array( $args['supports'][ $stable_support_key ] ) ) { /* - * To merge the alternative support config effectively, it also needs to be - * stabilized before merging to keep stabilized and experimental flags in - * sync. - */ + * To merge the alternative support config effectively, it also needs to be + * stabilized before merging to keep stabilized and experimental flags in + * sync. + */ $args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key ); $stable_config = $experimental_first ? array_merge( $stable_config, $args['supports'][ $stable_support_key ] ) From 9a6541f3af25ba0e8681c60a35b53dabb91ec4cf Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Fri, 20 Dec 2024 20:09:31 +0530 Subject: [PATCH 6/6] Add to backport changelog --- backport-changelog/6.8/7069.md | 1 + 1 file changed, 1 insertion(+) diff --git a/backport-changelog/6.8/7069.md b/backport-changelog/6.8/7069.md index 69edbde58902d1..44ab91ab3ff214 100644 --- a/backport-changelog/6.8/7069.md +++ b/backport-changelog/6.8/7069.md @@ -3,3 +3,4 @@ https://github.com/WordPress/wordpress-develop/pull/7069 * https://github.com/WordPress/gutenberg/pull/63401 * https://github.com/WordPress/gutenberg/pull/66918 * https://github.com/WordPress/gutenberg/pull/67018 +* https://github.com/WordPress/gutenberg/pull/68196