From dcbdba965effdca041c31262e22eaf1f906e1276 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 14:22:23 +0500 Subject: [PATCH 01/13] Block Hooks: Respect `"multiple": false` --- src/wp-includes/blocks.php | 53 ++++++++- .../tests/blocks/applyBlockHooksToContent.php | 101 ++++++++++++++++++ 2 files changed, 153 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index a479992faa4ca..a7f825687654e 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1056,9 +1056,60 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h $after_block_visitor = make_after_block_visitor( $hooked_blocks, $context, $callback ); } + $block_allows_multiple_instances = array(); + // Remove hooked blocks from the list if they have `multiple` set to false and are already + // present in `$content`. + foreach ( $hooked_blocks as &$relative_positions ) { + foreach ( $relative_positions as &$hooked_block_types ) { + foreach ( $hooked_block_types as &$hooked_block_type ) { + $hooked_block_type_definition = + WP_Block_Type_Registry::get_instance()->get_registered( $hooked_block_type ); + if ( block_has_support( $hooked_block_type_definition, 'multiple', true ) ) { + $block_allows_multiple_instances[ $hooked_block_type ] = true; + } elseif ( has_block( $hooked_block_type, $content ) ) { + unset( $hooked_block_type ); + if ( empty( $hooked_block_types ) ) { + unset( $hooked_block_types ); + } + if ( empty( $relative_positions ) ) { + unset( $relative_positions ); + } + } + } + } + } + + // We also need to cover the case where there the hooked block is not present in + // `$content` at first and we're allowed to insert it once -- but not again. + $suppress_single_instance_blocks = function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, $content ) { + foreach ( $hooked_block_types as $index => $hooked_block_type ) { + if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { + $hooked_block_type_definition = + WP_Block_Type_Registry::get_instance()->get_registered( $hooked_block_type ); + + $block_allows_multiple_instances[ $hooked_block_type ] = + block_has_support( $hooked_block_type_definition, 'multiple', true ); + + if ( ! $block_allows_multiple_instances[ $hooked_block_type ] && has_block( $hooked_block_type, $content ) ) { + unset( $hooked_block_types[ $index ] ); + } + } elseif ( ! $block_allows_multiple_instances[ $hooked_block_type ] ) { + // An instance of the hooked block was previously encountered, and its `multiple` support is false. + unset( $hooked_block_types[ $index ] ); + } + } + + return $hooked_block_types; + }; + add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX, 3 ); + $blocks = parse_blocks( $content ); - return traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); + $updated_content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); + + remove_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX ); + + return $updated_content; } /** diff --git a/tests/phpunit/tests/blocks/applyBlockHooksToContent.php b/tests/phpunit/tests/blocks/applyBlockHooksToContent.php index 61f594d011de1..f238ef6ff5266 100644 --- a/tests/phpunit/tests/blocks/applyBlockHooksToContent.php +++ b/tests/phpunit/tests/blocks/applyBlockHooksToContent.php @@ -27,6 +27,27 @@ public static function wpSetUpBeforeClass() { ), ) ); + + register_block_type( + 'tests/hooked-block-with-multiple-false', + array( + 'block_hooks' => array( + 'tests/other-anchor-block' => 'after', + ), + 'supports' => array( + 'multiple' => false, + ), + ) + ); + + register_block_type( + 'tests/dynamically-hooked-block-with-multiple-false', + array( + 'supports' => array( + 'multiple' => false, + ), + ) + ); } /** @@ -38,6 +59,8 @@ public static function wpTearDownAfterClass() { $registry = WP_Block_Type_Registry::get_instance(); $registry->unregister( 'tests/hooked-block' ); + $registry->unregister( 'tests/hooked-block-with-multiple-false' ); + $registry->unregister( 'tests/dynamically-hooked-block-with-multiple-false' ); } /** @@ -67,4 +90,82 @@ public function test_apply_block_hooks_to_content_inserts_hooked_block() { $actual ); } + + /** + * @ticket 61902 + */ + public function test_apply_block_hooks_to_content_respect_multiple_false() { + $context = new WP_Block_Template(); + $context->content = ''; + + $actual = apply_block_hooks_to_content( $context->content, $context, 'insert_hooked_blocks' ); + $this->assertSame( + '', + $actual + ); + } + + /** + * @ticket 61902 + */ + public function test_apply_block_hooks_to_content_respect_multiple_false_after_inserting_once() { + $context = new WP_Block_Template(); + $context->content = ''; + + $actual = apply_block_hooks_to_content( $context->content, $context, 'insert_hooked_blocks' ); + $this->assertSame( + '', + $actual + ); + } + + /** + * @ticket 61902 + */ + public function test_apply_block_hooks_to_content_respect_multiple_false_with_filter() { + $filter = function ( $hooked_block_types, $relative_position, $anchor_block_type ) { + if ( 'tests/yet-another-anchor-block' === $anchor_block_type && 'after' === $relative_position ) { + $hooked_block_types[] = 'tests/dynamically-hooked-block-with-multiple-false'; + } + + return $hooked_block_types; + }; + + $context = new WP_Block_Template(); + $context->content = ''; + + add_filter( 'hooked_block_types', $filter, 10, 3 ); + $actual = apply_block_hooks_to_content( $context->content, $context, 'insert_hooked_blocks' ); + remove_filter( 'hooked_block_types', $filter, 10 ); + + $this->assertSame( + '', + $actual + ); + } + + /** + * @ticket 61902 + */ + public function test_apply_block_hooks_to_content_respect_multiple_false_after_inserting_once_with_filter() { + $filter = function ( $hooked_block_types, $relative_position, $anchor_block_type ) { + if ( 'tests/yet-another-anchor-block' === $anchor_block_type && 'after' === $relative_position ) { + $hooked_block_types[] = 'tests/dynamically-hooked-block-with-multiple-false'; + } + + return $hooked_block_types; + }; + + $context = new WP_Block_Template(); + $context->content = ''; + + add_filter( 'hooked_block_types', $filter, 10, 3 ); + $actual = apply_block_hooks_to_content( $context->content, $context, 'insert_hooked_blocks' ); + remove_filter( 'hooked_block_types', $filter, 10 ); + + $this->assertSame( + '', + $actual + ); + } } From 7affa65767db28221727b9f8423042f53b194ef4 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 14:33:30 +0500 Subject: [PATCH 02/13] Polish a little --- src/wp-includes/blocks.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index a7f825687654e..3be1c74e3cc79 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1102,14 +1102,14 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h return $hooked_block_types; }; add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX, 3 ); - - $blocks = parse_blocks( $content ); - - $updated_content = traverse_and_serialize_blocks( $blocks, $before_block_visitor, $after_block_visitor ); - + $content = traverse_and_serialize_blocks( + parse_blocks( $content ), + $before_block_visitor, + $after_block_visitor + ); remove_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX ); - return $updated_content; + return $content; } /** From c1319fca0d611514a61c8fff1f4d1f3a41154b38 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 15:20:34 +0500 Subject: [PATCH 03/13] Make anonymous function static --- src/wp-includes/blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 3be1c74e3cc79..5447904f6291b 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1081,7 +1081,7 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h // We also need to cover the case where there the hooked block is not present in // `$content` at first and we're allowed to insert it once -- but not again. - $suppress_single_instance_blocks = function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, $content ) { + $suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, $content ) { foreach ( $hooked_block_types as $index => $hooked_block_type ) { if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { $hooked_block_type_definition = From 034146ffeaae2da7d9a9b391a553b41d137b9ce2 Mon Sep 17 00:00:00 2001 From: Bernie Reiter <96308+ockham@users.noreply.github.com> Date: Fri, 27 Sep 2024 13:51:31 +0200 Subject: [PATCH 04/13] Correctly format multi-line comment Co-authored-by: Jon Surrell --- src/wp-includes/blocks.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 5447904f6291b..0155ef0d5d7d5 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1057,8 +1057,10 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } $block_allows_multiple_instances = array(); - // Remove hooked blocks from the list if they have `multiple` set to false and are already - // present in `$content`. + /* + * Remove hooked blocks from the list if they have `multiple` set to false and are already + * present in `$content`. + */ foreach ( $hooked_blocks as &$relative_positions ) { foreach ( $relative_positions as &$hooked_block_types ) { foreach ( $hooked_block_types as &$hooked_block_type ) { From a3c1b823f10360282e4f5b7e5648651f1d146437 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 16:52:42 +0500 Subject: [PATCH 05/13] Slightly rephrase comment --- src/wp-includes/blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 0155ef0d5d7d5..0298f4c072f8f 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1058,8 +1058,8 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h $block_allows_multiple_instances = array(); /* - * Remove hooked blocks from the list if they have `multiple` set to false and are already - * present in `$content`. + * Remove hooked blocks from `$hooked_block_types` if they have `multiple` set to false and + * are already present in `$content`. */ foreach ( $hooked_blocks as &$relative_positions ) { foreach ( $relative_positions as &$hooked_block_types ) { From 92d89205f50f25d672efae7d229099bc5df46d1d Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 16:53:44 +0500 Subject: [PATCH 06/13] Another multi-line comment --- src/wp-includes/blocks.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 0298f4c072f8f..36bc098b1cbca 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1081,8 +1081,10 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } } - // We also need to cover the case where there the hooked block is not present in - // `$content` at first and we're allowed to insert it once -- but not again. + /* + * We also need to cover the case where there the hooked block is not present in + * `$content` at first and we're allowed to insert it once -- but not again. + */ $suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, $content ) { foreach ( $hooked_block_types as $index => $hooked_block_type ) { if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { From 257225c98c4a4354aa89c841b0663ca91c24c6ca Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Fri, 27 Sep 2024 18:08:09 +0500 Subject: [PATCH 07/13] Revert "Use references instead of indices in loop" This reverts commit 40bac1c0cd582996415f535d1a5a7f76b0817125. --- src/wp-includes/blocks.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 36bc098b1cbca..3198c3893b939 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1061,20 +1061,20 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h * Remove hooked blocks from `$hooked_block_types` if they have `multiple` set to false and * are already present in `$content`. */ - foreach ( $hooked_blocks as &$relative_positions ) { - foreach ( $relative_positions as &$hooked_block_types ) { - foreach ( $hooked_block_types as &$hooked_block_type ) { + foreach ( $hooked_blocks as $anchor_block_type => $relative_positions ) { + foreach ( $relative_positions as $relative_position => $hooked_block_types ) { + foreach ( $hooked_block_types as $index => $hooked_block_type ) { $hooked_block_type_definition = WP_Block_Type_Registry::get_instance()->get_registered( $hooked_block_type ); if ( block_has_support( $hooked_block_type_definition, 'multiple', true ) ) { $block_allows_multiple_instances[ $hooked_block_type ] = true; } elseif ( has_block( $hooked_block_type, $content ) ) { - unset( $hooked_block_type ); - if ( empty( $hooked_block_types ) ) { - unset( $hooked_block_types ); + unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ][ $index ] ); + if ( empty( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ) ) { + unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ); } - if ( empty( $relative_positions ) ) { - unset( $relative_positions ); + if ( empty( $hooked_blocks[ $anchor_block_type ] ) ) { + unset( $hooked_blocks[ $anchor_block_type ] ); } } } From fab670052f4e6c70555014730994d1473deeecf7 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 09:30:03 +0500 Subject: [PATCH 08/13] Prune only after finishing loop --- src/wp-includes/blocks.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 3198c3893b939..5d1d07ae2aac2 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1070,14 +1070,14 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h $block_allows_multiple_instances[ $hooked_block_type ] = true; } elseif ( has_block( $hooked_block_type, $content ) ) { unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ][ $index ] ); - if ( empty( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ) ) { - unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ); - } - if ( empty( $hooked_blocks[ $anchor_block_type ] ) ) { - unset( $hooked_blocks[ $anchor_block_type ] ); - } } } + if ( empty( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ) ) { + unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ] ); + } + } + if ( empty( $hooked_blocks[ $anchor_block_type ] ) ) { + unset( $hooked_blocks[ $anchor_block_type ] ); } } From 0b563b0178b5f3d88eb0cb650b4db98ba74e0907 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 11:14:43 +0500 Subject: [PATCH 09/13] Optimize a bit more --- src/wp-includes/blocks.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 5d1d07ae2aac2..6f4cff400e9ef 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1066,9 +1066,14 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h foreach ( $hooked_block_types as $index => $hooked_block_type ) { $hooked_block_type_definition = WP_Block_Type_Registry::get_instance()->get_registered( $hooked_block_type ); - if ( block_has_support( $hooked_block_type_definition, 'multiple', true ) ) { - $block_allows_multiple_instances[ $hooked_block_type ] = true; - } elseif ( has_block( $hooked_block_type, $content ) ) { + + $block_allows_multiple_instances[ $hooked_block_type ] = + block_has_support( $hooked_block_type_definition, 'multiple', true ); + + if ( + ! $block_allows_multiple_instances[ $hooked_block_type ] && + has_block( $hooked_block_type, $content ) + ) { unset( $hooked_blocks[ $anchor_block_type ][ $relative_position ][ $index ] ); } } @@ -1081,11 +1086,12 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } } + $single_instance_blocks_present_in_content = array(); /* * We also need to cover the case where there the hooked block is not present in * `$content` at first and we're allowed to insert it once -- but not again. */ - $suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, $content ) { + $suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, &$single_instance_blocks_present_in_content, $content ) { foreach ( $hooked_block_types as $index => $hooked_block_type ) { if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { $hooked_block_type_definition = @@ -1093,16 +1099,23 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h $block_allows_multiple_instances[ $hooked_block_type ] = block_has_support( $hooked_block_type_definition, 'multiple', true ); + } - if ( ! $block_allows_multiple_instances[ $hooked_block_type ] && has_block( $hooked_block_type, $content ) ) { - unset( $hooked_block_types[ $index ] ); - } - } elseif ( ! $block_allows_multiple_instances[ $hooked_block_type ] ) { - // An instance of the hooked block was previously encountered, and its `multiple` support is false. + if ( $block_allows_multiple_instances[ $hooked_block_type ] ) { + continue; + } + + // The block doesn't allow multiple instances, so we need to check if it's already present. + if ( + in_array( $hooked_block_type, $single_instance_blocks_present_in_content, true ) || + has_block( $hooked_block_type, $content ) + ) { unset( $hooked_block_types[ $index ] ); + } else { + // Remember not to insert this block again. + $single_instance_blocks_present_in_content[] = $hooked_block_type; } } - return $hooked_block_types; }; add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX, 3 ); From 05db29bfea3dec588b59e0781c0150aab04ef271 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 11:17:42 +0500 Subject: [PATCH 10/13] Remove unnecessary function args from filter --- src/wp-includes/blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 6f4cff400e9ef..6a608378c4380 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1091,7 +1091,7 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h * We also need to cover the case where there the hooked block is not present in * `$content` at first and we're allowed to insert it once -- but not again. */ - $suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_name ) use ( &$block_allows_multiple_instances, &$single_instance_blocks_present_in_content, $content ) { + $suppress_single_instance_blocks = static function ( $hooked_block_types ) use ( &$block_allows_multiple_instances, &$single_instance_blocks_present_in_content, $content ) { foreach ( $hooked_block_types as $index => $hooked_block_type ) { if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { $hooked_block_type_definition = @@ -1118,7 +1118,7 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } return $hooked_block_types; }; - add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX, 3 ); + add_filter( 'hooked_block_types', $suppress_single_instance_blocks, PHP_INT_MAX ); $content = traverse_and_serialize_blocks( parse_blocks( $content ), $before_block_visitor, From a3d11b98efd9eb3809f151b38d67a1e5be354b03 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 11:26:43 +0500 Subject: [PATCH 11/13] Move single_instance_blocks_present_in_content into filter, make static --- src/wp-includes/blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 6a608378c4380..c218e728105b3 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1086,12 +1086,12 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } } - $single_instance_blocks_present_in_content = array(); /* * We also need to cover the case where there the hooked block is not present in * `$content` at first and we're allowed to insert it once -- but not again. */ - $suppress_single_instance_blocks = static function ( $hooked_block_types ) use ( &$block_allows_multiple_instances, &$single_instance_blocks_present_in_content, $content ) { + $suppress_single_instance_blocks = static function ( $hooked_block_types ) use ( &$block_allows_multiple_instances, $content ) { + static $single_instance_blocks_present_in_content = array(); foreach ( $hooked_block_types as $index => $hooked_block_type ) { if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) { $hooked_block_type_definition = From 95c4140afcca782a7f7e4a846931d92220286a4a Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 13:25:54 +0500 Subject: [PATCH 12/13] Typo --- src/wp-includes/blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index c218e728105b3..9b5288b690dba 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1087,7 +1087,7 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h } /* - * We also need to cover the case where there the hooked block is not present in + * We also need to cover the case where the hooked block is not present in * `$content` at first and we're allowed to insert it once -- but not again. */ $suppress_single_instance_blocks = static function ( $hooked_block_types ) use ( &$block_allows_multiple_instances, $content ) { From 3bf035b548f3231d7d60d8bc03dec431fe57585f Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Mon, 30 Sep 2024 13:26:34 +0500 Subject: [PATCH 13/13] Rephrase comment --- src/wp-includes/blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 9b5288b690dba..998a50a400c97 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -1112,7 +1112,7 @@ function apply_block_hooks_to_content( $content, $context, $callback = 'insert_h ) { unset( $hooked_block_types[ $index ] ); } else { - // Remember not to insert this block again. + // We can insert the block once, but need to remember not to insert it again. $single_instance_blocks_present_in_content[] = $hooked_block_type; } }