WP_Navigation_Block_Renderer::get_inner_blocks_from_navigation_post()
Gets the inner blocks for the navigation block from the navigation post.
Метод класса: WP_Navigation_Block_Renderer{}
Хуков нет.
Возвращает
WP_Block_List
. Returns the inner blocks for the navigation block.
Использование
$result = WP_Navigation_Block_Renderer::get_inner_blocks_from_navigation_post( $attributes );
- $attributes(массив) (обязательный)
- The block attributes.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Navigation_Block_Renderer::get_inner_blocks_from_navigation_post() WP Navigation Block Renderer::get inner blocks from navigation post WP 6.7.1
private static function get_inner_blocks_from_navigation_post( $attributes ) { $navigation_post = get_post( $attributes['ref'] ); if ( ! isset( $navigation_post ) ) { return new WP_Block_List( array(), $attributes ); } // Only published posts are valid. If this is changed then a corresponding change // must also be implemented in `use-navigation-menu.js`. if ( 'publish' === $navigation_post->post_status ) { $parsed_blocks = parse_blocks( $navigation_post->post_content ); // 'parse_blocks' includes a null block with '\n\n' as the content when // it encounters whitespace. This code strips it. $blocks = block_core_navigation_filter_out_empty_blocks( $parsed_blocks ); // Run Block Hooks algorithm to inject hooked blocks. $markup = block_core_navigation_insert_hooked_blocks( $blocks, $navigation_post ); $root_nav_block = parse_blocks( $markup )[0]; $blocks = isset( $root_nav_block['innerBlocks'] ) ? $root_nav_block['innerBlocks'] : $blocks; // TODO - this uses the full navigation block attributes for the // context which could be refined. return new WP_Block_List( $blocks, $attributes ); } }