wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



block_core_navigation_mock_parsed_block › WordPress Function

Seitn/v
Veraltetn/v
block_core_navigation_mock_parsed_block ( $inner_blocks, $post )
Parameter: (2)
  • (array) $inner_blocks Parsed inner blocks of a Navigation block.
    Erforderlich: Ja
  • (WP_Post) $post `wp_navigation` post object corresponding to the block.
    Erforderlich: Ja
Gibt zurück:
  • (array) the normalized parsed blocks.
Definiert in:
Codex:

Mock a parsed block for the Navigation block given its inner blocks and the `wp_navigation` post object.

The wp_navigation post's _wp_ignored_hooked_blocks meta is queried to add the metadata.ignoredHookedBlocks attribute.


Quellcode

function block_core_navigation_mock_parsed_block( $inner_blocks, $post ) {
	$attributes = array();

	if ( isset( $post->ID ) ) {
		$ignored_hooked_blocks = get_post_meta( $post->ID, '_wp_ignored_hooked_blocks', true );
		if ( ! empty( $ignored_hooked_blocks ) ) {
			$ignored_hooked_blocks  = json_decode( $ignored_hooked_blocks, true );
			$attributes['metadata'] = array(
				'ignoredHookedBlocks' => $ignored_hooked_blocks,
			);
		}
	}

	$mock_anchor_parent_block = array(
		'blockName'    => 'core/navigation',
		'attrs'        => $attributes,
		'innerBlocks'  => $inner_blocks,
		'innerContent' => array_fill( 0, count( $inner_blocks ), null ),
	);

	return $mock_anchor_parent_block;
}