Posts: Prevent an empty excerpt when groups and nested column blocks are present.

This improves the logic within `excerpt_remove_blocks()` to better handle `innerBlocks`. This prevents an empty excerpt from being returned when `core/columns`, `core/column`, and `core/group` blocks are present.

This issue has been surfaced in the Query Loop block, where excerpts can be set to display. 

Props aristath.
Fixes #53604.
Built from https://develop.svn.wordpress.org/trunk@51348


git-svn-id: http://core.svn.wordpress.org/trunk@50957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj
2021-07-06 15:32:57 +00:00
parent 5ab81a5f38
commit 98579e4495
4 changed files with 53 additions and 18 deletions

View File

@@ -25,13 +25,15 @@ function render_block_core_legacy_widget( $attributes ) {
}
$id_base = $attributes['idBase'];
if ( method_exists( $wp_widget_factory, 'get_widget_key' ) ) {
$widget_key = $wp_widget_factory->get_widget_key( $id_base );
if ( method_exists( $wp_widget_factory, 'get_widget_key' ) && method_exists( $wp_widget_factory, 'get_widget_object' ) ) {
$widget_key = $wp_widget_factory->get_widget_key( $id_base );
$widget_object = $wp_widget_factory->get_widget_object( $id_base );
} else {
$widget_key = gutenberg_get_widget_key( $id_base );
$widget_key = gutenberg_get_widget_key( $id_base );
$widget_object = gutenberg_get_widget_object( $id_base );
}
if ( ! $widget_key ) {
if ( ! $widget_key || ! $widget_object ) {
return '';
}
@@ -45,8 +47,13 @@ function render_block_core_legacy_widget( $attributes ) {
$instance = array();
}
$args = array(
'widget_id' => $widget_object->id,
'widget_name' => $widget_object->name,
);
ob_start();
the_widget( $widget_key, $instance );
the_widget( $widget_key, $instance, $args );
return ob_get_clean();
}