Skip to content

Commit b931185

Browse files
committed
Add/move comments
1 parent a25d4a7 commit b931185

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/wp-includes/blocks.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,11 +1125,12 @@ function apply_block_hooks_to_content( $content, $context = null, $callback = 'i
11251125
}
11261126
}
11271127

1128-
/*
1129-
* We also need to cover the case where the hooked block is not present in
1130-
* `$content` at first and we're allowed to insert it once -- but not again.
1131-
*/
11321128
$suppress_single_instance_blocks = static function ( $hooked_block_types, $relative_position, $anchor_block_type ) use ( &$block_allows_multiple_instances, $content, $context ) {
1129+
/*
1130+
* If the context is a post object, we need to avoid inserting any blocks hooked into the
1131+
* `before` and `after` positions of the temporary wrapper block that we create to wrap the content.
1132+
* See https://core.trac.wordpress.org/ticket/63287 for more details.
1133+
*/
11331134
if ( $context instanceof WP_Post ) {
11341135
$wrapper_block_type = 'core/post-content';
11351136
if ( 'wp_navigation' === $context->post_type ) {
@@ -1146,6 +1147,10 @@ function apply_block_hooks_to_content( $content, $context = null, $callback = 'i
11461147
}
11471148
}
11481149

1150+
/*
1151+
* We also need to cover the case where a hooked block with `multiple: false` is not
1152+
* present in `$content` at first and we're allowed to insert it once -- but not again.
1153+
*/
11491154
static $single_instance_blocks_present_in_content = array();
11501155
foreach ( $hooked_block_types as $index => $hooked_block_type ) {
11511156
if ( ! isset( $block_allows_multiple_instances[ $hooked_block_type ] ) ) {

0 commit comments

Comments
 (0)