Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Renderer::handle_render_block_context
Extend context only for Product Collection blocks and their descendants.
Method of the class: Renderer{}
No Hooks.
Returns
array.
Usage
$Renderer = new Renderer(); $Renderer->handle_render_block_context( $context, $parsed_block, $parent_block );
- $context(array) (required)
- The block context.
- $parsed_block(array) (required)
- The parsed block being rendered.
- $parent_block(WP_Block|null)
- The parent block instance, or null for a top-level block.
Default:null
Changelog
| Since 11.3.0 | Introduced. |
Renderer::handle_render_block_context() Renderer::handle render block context code 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 );
}