diff --git a/src/BlockTypes/ProductButton.php b/src/BlockTypes/ProductButton.php
index 370195e3d4e..ec7a5670a1c 100644
--- a/src/BlockTypes/ProductButton.php
+++ b/src/BlockTypes/ProductButton.php
@@ -102,8 +102,8 @@ protected function render( $attributes, $content, $block ) {
esc_attr( $product->get_sku() ),
$product->is_purchasable() ? 'ajax_add_to_cart add_to_cart_button' : '',
esc_attr( $product->get_type() ),
- $styles_and_classes['classes'],
- $styles_and_classes['styles'],
+ esc_attr( $styles_and_classes['classes'] ),
+ esc_attr( $styles_and_classes['styles'] ),
esc_html( $product->add_to_cart_text() ),
$html_element
),
diff --git a/src/BlockTypes/ProductCategoryList.php b/src/BlockTypes/ProductCategoryList.php
index 81e96aaaa13..bbf736c1013 100644
--- a/src/BlockTypes/ProductCategoryList.php
+++ b/src/BlockTypes/ProductCategoryList.php
@@ -89,18 +89,23 @@ protected function render( $attributes, $content, $block ) {
$output = '';
$output .= '
-
- ' . __( 'Categories:', 'woo-gutenberg-products-block' )
- . '
';
return $output;
}
diff --git a/src/BlockTypes/ProductImage.php b/src/BlockTypes/ProductImage.php
index 591b883e369..0dd806f2f77 100644
--- a/src/BlockTypes/ProductImage.php
+++ b/src/BlockTypes/ProductImage.php
@@ -105,8 +105,8 @@ private function render_on_sale_badge( $product, $attributes ) {
',
$attributes['saleBadgeAlign'],
- isset( $font_size['class'] ) ? $font_size['class'] : '',
- isset( $font_size['style'] ) ? $font_size['style'] : '',
+ isset( $font_size['class'] ) ? esc_attr( $font_size['class'] ) : '',
+ isset( $font_size['style'] ) ? esc_attr( $font_size['style'] ) : '',
esc_html__( 'Sale', 'woo-gutenberg-products-block' )
);
return $on_sale_badge;
@@ -199,8 +199,8 @@ protected function render( $attributes, $content, $block ) {
'
%3$s
',
- isset( $border_radius['style'] ) ? $border_radius['style'] : '',
- isset( $margin['style'] ) ? $margin['style'] : '',
+ isset( $border_radius['style'] ) ? esc_attr( $border_radius['style'] ) : '',
+ isset( $margin['style'] ) ? esc_attr( $margin['style'] ) : '',
$this->render_anchor(
$product,
$this->render_on_sale_badge( $product, $parsed_attributes ),
diff --git a/src/BlockTypes/ProductSaleBadge.php b/src/BlockTypes/ProductSaleBadge.php
index 68826e8f442..fd72aeed564 100644
--- a/src/BlockTypes/ProductSaleBadge.php
+++ b/src/BlockTypes/ProductSaleBadge.php
@@ -98,13 +98,15 @@ protected function render( $attributes, $content, $block ) {
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
$classname = isset( $attributes['className'] ) ? $attributes['className'] : '';
- $output = '';
- $output .= '
';
+ $output = '
';
$output .= '' . __( 'Sale', 'woo-gutenberg-products-block' ) . '';
- $output .= '' . __(
- 'Product on sale',
- 'woo-gutenberg-products-block'
- ) . '';
+ $output .= ''
+ . __( 'Product on sale', 'woo-gutenberg-products-block' )
+ . '';
$output .= '
';
return $output;
diff --git a/src/Utils/StyleAttributesUtils.php b/src/Utils/StyleAttributesUtils.php
index cb46c807fed..0a126bf1c6f 100644
--- a/src/Utils/StyleAttributesUtils.php
+++ b/src/Utils/StyleAttributesUtils.php
@@ -341,7 +341,7 @@ public static function get_align_class_and_style( $attributes ) {
public static function get_spacing_value( $spacing_value ) {
// Used following code as reference: https://github.com/WordPress/gutenberg/blob/cff6d70d6ff5a26e212958623dc3130569f95685/lib/block-supports/layout.php/#L219-L225.
if ( is_string( $spacing_value ) && str_contains( $spacing_value, 'var:preset|spacing|' ) ) {
- $spacing_value = str_replace( 'var:preset|spacing|', '', 'var:preset|spacing|50' );
+ $spacing_value = str_replace( 'var:preset|spacing|', '', $spacing_value );
return sprintf( 'var(--wp--preset--spacing--%s)', $spacing_value );
}