block_core_navigation_block_contains_core_navigation

函数
block_core_navigation_block_contains_core_navigation ( $inner_blocks )
参数
  • (WP_Block_List) $inner_blocks Inner block instance to be normalized.
    Required:
返回值
  • (bool) true if the navigation block contains a nested navigation block.
定义位置
相关方法
block_core_navigation_build_css_colorsblock_core_navigation_get_most_recently_published_navigationblock_core_navigation_build_css_font_sizesblock_core_navigation_from_block_get_post_idsblock_core_navigation_link_build_css_font_sizes
引入
-
弃用
-

如果导航区块包含嵌套导航区块,则返回 true。

function block_core_navigation_block_contains_core_navigation( $inner_blocks ) {
	foreach ( $inner_blocks as $block ) {
		if ( 'core/navigation' === $block->name ) {
			return true;
		}
		if ( $block->inner_blocks && block_core_navigation_block_contains_core_navigation( $block->inner_blocks ) ) {
			return true;
		}
	}

	return false;
}

常见问题

FAQs
查看更多 >