diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 3c88f7b4c3..7795a6969b 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -956,6 +956,10 @@ function filter_block_kses_value( $value, $allowed_html, $allowed_protocols = ar * @return string The parsed and filtered content. */ function excerpt_remove_blocks( $content ) { + if ( ! has_blocks( $content ) ) { + return $content; + } + $allowed_inner_blocks = array( // Classic blocks have their blockName set to null. null, diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 05084329d3..0e5797fa7e 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -3980,18 +3980,29 @@ function wp_trim_excerpt( $text = '', $post = null ) { * within the excerpt are stripped out. Modifying the tags here * is wasteful and can lead to bugs in the image counting logic. */ - $filter_removed = remove_filter( 'the_content', 'wp_filter_content_tags' ); + $filter_image_removed = remove_filter( 'the_content', 'wp_filter_content_tags' ); + + /* + * Temporarily unhook do_blocks() since excerpt_remove_blocks( $text ) + * handels block rendering needed for excerpt. + */ + $filter_block_removed = remove_filter( 'the_content', 'do_blocks', 9 ); /** This filter is documented in wp-includes/post-template.php */ $text = apply_filters( 'the_content', $text ); $text = str_replace( ']]>', ']]>', $text ); - /** + // Restore the original filter if removed. + if ( $filter_block_removed ) { + add_filter( 'the_content', 'do_blocks', 9 ); + } + + /* * Only restore the filter callback if it was removed above. The logic * to unhook and restore only applies on the default priority of 10, * which is generally used for the filter callback in WordPress core. */ - if ( $filter_removed ) { + if ( $filter_image_removed ) { add_filter( 'the_content', 'wp_filter_content_tags' ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8d2df4d68f..ccbb89a59a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56559'; +$wp_version = '6.4-alpha-56560'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.