wpseek.com
WordPress开发者和主题制作者的搜索引擎



block_core_navigation_filter_out_empty_blocks › WordPress Function

Sincen/a
已弃用n/a
block_core_navigation_filter_out_empty_blocks ( $parsed_blocks )
参数:
  • (array) $parsed_blocks the parsed blocks to be normalized.
    Required: Yes
返回:
  • (array) the normalized parsed blocks.
定义在:
文档:

Filter out empty "null" blocks from the block list.

'parse_blocks' includes a null block with 'nn' as the content when it encounters whitespace. This is not a bug but rather how the parser is designed.


源码

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

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