Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Renderer::handle_render_block_context │ public │ WC 11.3.0

Extend context only for Product Collection blocks and their descendants.

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

Хуков нет.

Возвращает

array.

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

$Renderer = new Renderer();
$Renderer->handle_render_block_context( $context, $parsed_block, $parent_block );
$context(массив) (обязательный)
The block context.
$parsed_block(массив) (обязательный)
The parsed block being rendered.
$parent_block(WP_Block|null)
The parent block instance, or null for a top-level block.
По умолчанию: null

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

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

Код Renderer::handle_render_block_context() WC 11.3.0

public function handle_render_block_context( $context, $parsed_block, $parent_block = null ) {
	$block_name = $parsed_block['blockName'] ?? '';

	if (
		'woocommerce/product-collection' !== $block_name &&
		(
			! $parent_block instanceof \WP_Block ||
			( 'woocommerce/product-collection' !== $parent_block->name && ( ! isset( $parent_block->context['isProductCollectionInnerBlock'] ) || true !== ( $parent_block->context['isProductCollectionInnerBlock'] ) ) )
		)
	) {
		return $context;
	}

	return $this->extend_context_for_inner_blocks( $context, $parsed_block );
}