Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Renderer::add_navigation_link_directives()
Add interactive links to all anchors inside the Query Pagination block. This enabled client-side navigation for the product collection block.
Method of the class: Renderer{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Renderer = new Renderer(); $Renderer->add_navigation_link_directives( $block_content, $block, $instance );
- $block_content(string) (required)
- The block content.
- $block(array) (required)
- The full block, including name and attributes.
- $instance(\WP_Block) (required)
- The block instance.
Renderer::add_navigation_link_directives() Renderer::add navigation link directives code WC 9.6.0
public function add_navigation_link_directives( $block_content, $block, $instance ) { $query_context = $instance->context['query'] ?? array(); $is_product_collection_block = $query_context['isProductCollectionBlock'] ?? false; $query_id = $instance->context['queryId'] ?? null; $parsed_query_id = $this->parsed_block['attrs']['queryId'] ?? null; $is_enhanced_pagination_enabled = ! ( $this->parsed_block['attrs']['forcePageReload'] ?? false ); // Only proceed if the block is a product collection block, // enhanced pagination is enabled and query IDs match. if ( $is_product_collection_block && $is_enhanced_pagination_enabled && $query_id === $parsed_query_id ) { $block_content = $this->process_pagination_links( $block_content ); } return $block_content; }