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



block_core_navigation_mock_parsed_block › WordPress Function

Sincen/a
已弃用n/a
block_core_navigation_mock_parsed_block ( $inner_blocks, $post )
参数: (2)
  • (array) $inner_blocks Parsed inner blocks of a Navigation block.
    Required: Yes
  • (WP_Post) $post `wp_navigation` post object corresponding to the block.
    Required: Yes
返回:
  • (array) the normalized parsed blocks.
定义在:
文档:

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.


源码

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