context['postId'] ) && ! empty( $instance->context['query']['postType'] ) && 'product' === $instance->context['query']['postType']; if ( ! $is_inside_product_template ) { return $html; } // Cache theme mod values to avoid repeated DB queries per block if ( null === self::$enable_zoom ) { self::$enable_zoom = get_theme_mod( 'enable_product_image_hover_zoom', true ); } if ( ! self::$enable_zoom ) { return $html; } if ( null === self::$hover_scale ) { self::$hover_scale = get_theme_mod( 'product_image_hover_scale', 1.1 ); } $product_image_hover_scale = self::$hover_scale; $tag = new \WP_HTML_Tag_Processor( $html ); if ( $tag->next_tag() ) { $tag->set_attribute( 'data-zoom-hover', 'true' ); $escape_styles = array(); $escape_styles[] = '--zoom-hover-scale: ' . $product_image_hover_scale . ';'; $updated_style = ''; if ( empty( $existing_style ) ) { $existing_style = ''; } elseif ( ! str_ends_with( $existing_style, ';' ) ) { $existing_style .= ';'; } $updated_style = $existing_style; $updated_style .= implode( ';', $escape_styles ); if ( ! empty( $escape_styles ) ) { $updated_style .= ';'; } $tag->set_attribute( 'style', $updated_style ); $html = $tag->get_updated_html(); } return $html; } }