block_core_navigation_block_contains_core_navigation()WP 6.2.0

Returns true if the navigation block contains a nested navigation block.

Хуков нет.

Возвращает

true|false. true if the navigation block contains a nested navigation block.

Использование

block_core_navigation_block_contains_core_navigation( $inner_blocks );
$inner_blocks(WP_Block_List) (обязательный)
Inner block instance to be normalized.

Список изменений

С версии 6.2.0 Введена.

Код block_core_navigation_block_contains_core_navigation() WP 6.6.2

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;
}