block_core_navigation_filter_out_empty_blocks()WP 1.0

Filter out empty "null" blocks from the block list. 'parse_blocks' includes a null block with '\n\n' as the content when it encounters whitespace. This is not a bug but rather how the parser is designed.

Хуков нет.


Массив. the normalized parsed blocks.


block_core_navigation_filter_out_empty_blocks( $parsed_blocks );
$parsed_blocks(массив) (обязательный)
the parsed blocks to be normalized.

Код block_core_navigation_filter_out_empty_blocks() WP 6.5.5

function block_core_navigation_filter_out_empty_blocks( $parsed_blocks ) {
	$filtered = array_filter(
		static function ( $block ) {
			return isset( $block['blockName'] );

	// Reset keys.
	return array_values( $filtered );