wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



block_core_navigation_filter_out_empty_blocks › WordPress Function

Dan/a
Deprecaton/a
block_core_navigation_filter_out_empty_blocks ( $parsed_blocks )
Parametri:
  • (array) $parsed_blocks the parsed blocks to be normalized.
    Richiesto:
Ritorna:
  • (array) the normalized parsed blocks.
Definito a:
Codex:

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.


Sorgenti

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 );
}