block_core_navigation_mock_parsed_block

The timeline below displays how wordpress function block_core_navigation_mock_parsed_block has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * 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.
 *
 * @param array   $inner_blocks Parsed inner blocks of a Navigation block.
 * @param WP_Post $post         `wp_navigation` post object corresponding to the block.
 *
 * @return array the normalized parsed blocks.
 */
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;
}