WP_Navigation_Block_Renderer::has_submenus()
Returns whether or not a navigation has a submenu.
Метод класса: WP_Navigation_Block_Renderer{}
Хуков нет.
Возвращает
true|false
. Returns whether or not a navigation has a submenu and also sets the member variable.
Использование
$result = WP_Navigation_Block_Renderer::has_submenus( $inner_blocks );
- $inner_blocks(WP_Block_List) (обязательный)
- The list of inner blocks.
Список изменений
С версии 6.5.0 | Введена. |
Код WP_Navigation_Block_Renderer::has_submenus() WP Navigation Block Renderer::has submenus WP 6.7.1
private static function has_submenus( $inner_blocks ) { if ( true === static::$has_submenus ) { return static::$has_submenus; } foreach ( $inner_blocks as $inner_block ) { // If this is a page list then work out if any of the pages have children. if ( 'core/page-list' === $inner_block->name ) { $all_pages = get_pages( array( 'sort_column' => 'menu_order,post_title', 'order' => 'asc', ) ); foreach ( (array) $all_pages as $page ) { if ( $page->post_parent ) { static::$has_submenus = true; break; } } } // If this is a navigation submenu then we know we have submenus. if ( 'core/navigation-submenu' === $inner_block->name ) { static::$has_submenus = true; break; } } return static::$has_submenus; }