WP_Navigation_Block_Renderer::get_inner_blocks()private staticWP 6.5.0

Gets the inner blocks for the navigation block.

Метод класса: WP_Navigation_Block_Renderer{}

Хуки из метода

Возвращает

WP_Block_List. Returns the inner blocks for the navigation block.

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

$result = WP_Navigation_Block_Renderer::get_inner_blocks( $attributes, $block );
$attributes(массив) (обязательный)
The block attributes.
$block(WP_Block) (обязательный)
The parsed block.

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

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

Код WP_Navigation_Block_Renderer::get_inner_blocks() WP 6.7.1

private static function get_inner_blocks( $attributes, $block ) {
	$inner_blocks = $block->inner_blocks;

	// Ensure that blocks saved with the legacy ref attribute name (navigationMenuId) continue to render.
	if ( array_key_exists( 'navigationMenuId', $attributes ) ) {
		$attributes['ref'] = $attributes['navigationMenuId'];
	}

	// If:
	// - the gutenberg plugin is active
	// - `__unstableLocation` is defined
	// - we have menu items at the defined location
	// - we don't have a relationship to a `wp_navigation` Post (via `ref`).
	// ...then create inner blocks from the classic menu assigned to that location.
	if (
		defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN &&
		array_key_exists( '__unstableLocation', $attributes ) &&
		! array_key_exists( 'ref', $attributes ) &&
		! empty( block_core_navigation_get_menu_items_at_location( $attributes['__unstableLocation'] ) )
	) {
		$inner_blocks = block_core_navigation_get_inner_blocks_from_unstable_location( $attributes );
	}

	// Load inner blocks from the navigation post.
	if ( array_key_exists( 'ref', $attributes ) ) {
		$inner_blocks = static::get_inner_blocks_from_navigation_post( $attributes );
	}

	// If there are no inner blocks then fallback to rendering an appropriate fallback.
	if ( empty( $inner_blocks ) ) {
		$inner_blocks = static::get_inner_blocks_from_fallback( $attributes );
	}

	/**
	 * Filter navigation block $inner_blocks.
	 * Allows modification of a navigation block menu items.
	 *
	 * @since 6.1.0
	 *
	 * @param \WP_Block_List $inner_blocks
	 */
	$inner_blocks = apply_filters( 'block_core_navigation_render_inner_blocks', $inner_blocks );

	$post_ids = block_core_navigation_get_post_ids( $inner_blocks );
	if ( $post_ids ) {
		_prime_post_caches( $post_ids, false, false );
	}

	return $inner_blocks;
}