WP_Block_List example

array_key_exists( '__unstableLocation', $attributes ) &&
        ! array_key_exists( 'ref', $attributes ) &&
        ! empty( block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ) )
    ) {
        $menu_items = block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] );
        if ( empty( $menu_items ) ) {
            return '';
        }

        $menu_items_by_parent_id = block_core_navigation_sort_menu_items_by_parent_id( $menu_items );
        $parsed_blocks           = block_core_navigation_parse_blocks_from_menu_items( $menu_items_by_parent_id[0]$menu_items_by_parent_id );
        $inner_blocks            = new WP_Block_List( $parsed_blocks$attributes );
    }

    // Load inner blocks from the navigation post.     if ( array_key_exists( 'ref', $attributes ) ) {
        $navigation_post = get_post( $attributes['ref'] );
        if ( ! isset( $navigation_post ) ) {
            return '';
        }

        // Only published posts are valid. If this is changed then a corresponding change         // must also be implemented in `use-navigation-menu.js`.
if ( ! empty( $block['innerBlocks'] ) ) {
            $child_context = $this->available_context;

            if ( ! empty( $this->block_type->provides_context ) ) {
                foreach ( $this->block_type->provides_context as $context_name => $attribute_name ) {
                    if ( array_key_exists( $attribute_name$this->attributes ) ) {
                        $child_context[ $context_name ] = $this->attributes[ $attribute_name ];
                    }
                }
            }

            $this->inner_blocks = new WP_Block_List( $block['innerBlocks']$child_context$registry );
        }

        if ( ! empty( $block['innerHTML'] ) ) {
            $this->inner_html = $block['innerHTML'];
        }

        if ( ! empty( $block['innerContent'] ) ) {
            $this->inner_content = $block['innerContent'];
        }
    }

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