Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Renderer::update_pagination_anchors()privateWC 1.0

Sets up data attributes required for interactivity and client-side navigation.

Method of the class: Renderer{}

No Hooks.

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->update_pagination_anchors( $processor, $class_name, $key_prefix );
$processor(\WP_HTML_Tag_Processor) (required)
The HTML tag processor.
$class_name(string) (required)
The class name of the anchor tags.
$key_prefix(string) (required)
The prefix for the data-wc-key attribute.

Renderer::update_pagination_anchors() code WC 9.6.1

private function update_pagination_anchors( $processor, $class_name, $key_prefix ) {
	// Start from the beginning of the block content.
	$processor->seek( 'start' );

	while ( $processor->next_tag(
		array(
			'tag_name'   => 'a',
			'class_name' => $class_name,
		)
	) ) {
		$this->set_product_collection_namespace( $processor );
		$processor->set_attribute( 'data-wc-on--click', 'actions.navigate' );
		$processor->set_attribute( 'data-wc-key', $key_prefix . '--' . esc_attr( wp_rand() ) );

		if ( in_array( $class_name, array( 'wp-block-query-pagination-next', 'wp-block-query-pagination-previous' ), true ) ) {
			$processor->set_attribute( 'data-wc-watch', 'callbacks.prefetch' );
			$processor->set_attribute( 'data-wc-on--mouseenter', 'actions.prefetchOnHover' );
		}
	}
}