_excerpt_render_inner_blocks( array $parsed_block, array $allowed_blocks ): string

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only by core. It is listed here for completeness.

Renders inner blocks from the allowed wrapper blocks for generating an excerpt.

Parameters

$parsed_blockarrayrequired
The parsed block.
$allowed_blocksarrayrequired
The list of allowed inner blocks.

Return

string The rendered inner blocks.

Source

function _excerpt_render_inner_blocks( $parsed_block, $allowed_blocks ) {
	$output = '';

	foreach ( $parsed_block['innerBlocks'] as $inner_block ) {
		// Hide the block whenever the value is boolean false, regardless of the
		// block's current visibility support. This prevents blocks that previously
		// supported visibility from unintentionally appearing on the front end
		// after their support was disabled.
		if ( false === ( $inner_block['attrs']['metadata']['blockVisibility'] ?? null ) ) {
			continue;
		}

		if ( ! in_array( $inner_block['blockName'], $allowed_blocks, true ) ) {
			continue;
		}

		if ( empty( $inner_block['innerBlocks'] ) ) {
			$output .= render_block( $inner_block );
		} else {
			$output .= _excerpt_render_inner_blocks( $inner_block, $allowed_blocks );
		}
	}

	return $output;
}

Changelog

VersionDescription
5.8.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.