diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 31f1b22469..838cd84a19 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -1248,8 +1248,25 @@ function apply_block_hooks_to_content_from_post_object( $content, $post = null, $content ); + /* + * We need to avoid inserting any blocks hooked into the `before` and `after` positions + * of the temporary wrapper block that we create to wrap the content. + * See https://core.trac.wordpress.org/ticket/63287 for more details. + */ + $suppress_blocks_from_insertion_before_and_after_wrapper_block = static function ( $hooked_block_types, $relative_position, $anchor_block_type ) use ( $wrapper_block_type ) { + if ( + $wrapper_block_type === $anchor_block_type && + in_array( $relative_position, array( 'before', 'after' ), true ) + ) { + return array(); + } + return $hooked_block_types; + }; + // Apply Block Hooks. + add_filter( 'hooked_block_types', $suppress_blocks_from_insertion_before_and_after_wrapper_block, PHP_INT_MAX, 3 ); $content = apply_block_hooks_to_content( $content, $post, $callback ); + remove_filter( 'hooked_block_types', $suppress_blocks_from_insertion_before_and_after_wrapper_block, PHP_INT_MAX ); // Finally, we need to remove the temporary wrapper block. $content = remove_serialized_parent_block( $content ); diff --git a/wp-includes/version.php b/wp-includes/version.php index b500e4d430..bc32483e8f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8.1-alpha-60188'; +$wp_version = '6.8.1-alpha-60189'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.