Automattic\WooCommerce\Blocks\BlockTypes

ProductImage::render_anchor()privateWC 1.0

Render anchor.

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

Хуков нет.

Возвращает

Строку.

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

// private - только в коде основоного (родительского) класса
$result = $this->render_anchor( $product, $on_sale_badge, $product_image, $attributes );
$product(\WC_Product) (обязательный)
Product object.
$on_sale_badge(строка) (обязательный)
Return value from $render_image.
$product_image(строка) (обязательный)
Return value from $render_on_sale_badge.
$attributes(массив) (обязательный)
Attributes.

Код ProductImage::render_anchor() WC 9.5.1

private function render_anchor( $product, $on_sale_badge, $product_image, $attributes ) {
	$product_permalink = $product->get_permalink();

	$is_link        = true === $attributes['showProductLink'];
	$pointer_events = $is_link ? '' : 'pointer-events: none;';
	$directive      = $is_link ? 'data-wc-on--click="woocommerce/product-collection::actions.viewProduct"' : '';

	return sprintf(
		'<a href="%1$s" style="%2$s" %3$s>%4$s %5$s</a>',
		$product_permalink,
		$pointer_events,
		$directive,
		$on_sale_badge,
		$product_image
	);
}