Automattic\WooCommerce\Blocks\BlockTypes
ProductImage::render_anchor()
Render anchor.
Method of the class: ProductImage{}
No Hooks.
Return
String
.
Usage
// private - for code of main (parent) class only $result = $this->render_anchor( $product, $on_sale_badge, $product_image, $attributes );
- $product(\WC_Product) (required)
- Product object.
- $on_sale_badge(string) (required)
- Return value from $render_image.
- $product_image(string) (required)
- Return value from $render_on_sale_badge.
- $attributes(array) (required)
- Attributes.
ProductImage::render_anchor() ProductImage::render anchor code WC 9.4.2
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 ); }