serialize_blocks example

$menu_items_by_parent_id = static::group_by_parent_id( $menu_items );

        $first_menu_item = isset( $menu_items_by_parent_id[0] )
            ? $menu_items_by_parent_id[0]
            : array();

        $inner_blocks = static::to_blocks(
            $first_menu_item,
            $menu_items_by_parent_id
        );

        return serialize_blocks( $inner_blocks );
    }

    /** * Returns an array of menu items grouped by the id of the parent menu item. * * @since 6.3.0 * * @param array $menu_items An array of menu items. * @return array */
    private static function group_by_parent_id( $menu_items ) {
        
foreach ( $sorted_menu_items as $menu_item ) {
        $menu_items_by_parent_id[ $menu_item->menu_item_parent ][] = $menu_item;
    }

    $inner_blocks = block_core_navigation_parse_blocks_from_menu_items(
        isset( $menu_items_by_parent_id[0] )
            ? $menu_items_by_parent_id[0]
            : array(),
        $menu_items_by_parent_id
    );

    return serialize_blocks( $inner_blocks );
}

/** * If there's a classic menu then use it as a fallback. * * @deprecated 6.3.0 Use WP_Navigation_Fallback::create_classic_menu_fallback() instead. * * @return array the normalized parsed blocks. */
function block_core_navigation_maybe_use_classic_menu_fallback() {

    
Home | Imprint | This part of the site doesn't use cookies.