From 8c413885bdb9162846cf74091f65a7c7dee36736 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Wed, 7 Jul 2021 19:09:41 +0000 Subject: [PATCH] Posts: Allow the list of wrapper blocks to be filtered. This introduces the `excerpt_allowed_wrapper_blocks` filter for controlling which blocks should be considered wrapper blocks. Wrapper blocks and their nested contents are not stripped by `excerpt_remove_blocks()`, allowing their contents to appear in generated excerpts. Follow up to [51348]. Props aristath, jorbin. See #53604. git-svn-id: https://develop.svn.wordpress.org/trunk@51375 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 824c041d58..c6ce8b5d38 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -716,6 +716,16 @@ function excerpt_remove_blocks( $content ) { 'core/group', ); + /** + * Filters the list of blocks that can be used as wrapper blocks, allowing + * excerpts to be generated from the `innerBlocks` of these warppers. + * + * @since 5.8.0 + * + * @param array $allowed_wrapper_blocks The list of allowed wrapper blocks. + */ + $allowed_wrapper_blocks = apply_filters( 'excerpt_allowed_wrapper_blocks', $allowed_wrapper_blocks ); + $allowed_blocks = array_merge( $allowed_inner_blocks, $allowed_wrapper_blocks ); /**