diff --git a/plugins/woocommerce/changelog/51910-51883-globalstep-test-extra-class-additional-css-classes-is-displayed-on-frontend-for-the-product-image-block b/plugins/woocommerce/changelog/51910-51883-globalstep-test-extra-class-additional-css-classes-is-displayed-on-frontend-for-the-product-image-block new file mode 100644 index 00000000000..79fbab0889d --- /dev/null +++ b/plugins/woocommerce/changelog/51910-51883-globalstep-test-extra-class-additional-css-classes-is-displayed-on-frontend-for-the-product-image-block @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Avoid duplicate custom classnames \ No newline at end of file diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php index 6d4ad2a8502..3a572a9e173 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php @@ -169,10 +169,10 @@ class AddToCartForm extends AbstractBlock { $product = $this->add_is_descendent_of_single_product_block_hidden_input_to_product_form( $product, $is_descendent_of_single_product_block ); } - $product = $this->add_classes_to_add_to_cart_form_input( $product, $attributes ); + $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); + $product = $this->add_classes_to_add_to_cart_form_input( $product, $attributes ); - $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); - $product_classname = $is_descendent_of_single_product_block ? 'product' : ''; + $product_classname = $is_descendent_of_single_product_block ? 'product' : ''; $classes = implode( ' ', diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php b/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php index fb0e0b1cc0e..f797d656d3e 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php @@ -34,7 +34,7 @@ class Breadcrumbs extends AbstractBlock { return; } - $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); + $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); return sprintf( '
%2$s
', diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php b/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php index 6f46707203c..23921389c4b 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/CatalogSorting.php @@ -35,7 +35,7 @@ class CatalogSorting extends AbstractBlock { return; } - $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); + $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductAverageRating.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductAverageRating.php index d4a2fedcbab..6f36591661d 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductAverageRating.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductAverageRating.php @@ -90,7 +90,7 @@ class ProductAverageRating extends AbstractBlock { return ''; } - $styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); + $styles_and_classes = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); $text_align_styles_and_classes = StyleAttributesUtils::get_text_align_class_and_style( $attributes ); $wrapper_attributes = get_block_wrapper_attributes( diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductGalleryPager.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductGalleryPager.php index ac478cc71c0..4076686660f 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductGalleryPager.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductGalleryPager.php @@ -56,8 +56,7 @@ class ProductGalleryPager extends AbstractBlock { } $number_of_thumbnails = $block->context['thumbnailsNumberOfThumbnails'] ?? 0; - $classname = StyleAttributesUtils::get_classes_by_attributes( $attributes, array( 'extra_classes' ) ); - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classname ) ) ); + $wrapper_attributes = get_block_wrapper_attributes(); $post_id = $block->context['postId'] ?? ''; $product = wc_get_product( $post_id ); diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php index e3875d8ffee..a5ee5f55c03 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php @@ -203,7 +203,7 @@ class ProductImage extends AbstractBlock { } $parsed_attributes = $this->parse_attributes( $attributes ); - $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); + $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); $post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : ''; $product = wc_get_product( $post_id ); diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php b/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php index 9addff1a630..bfc56c8ac55 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php @@ -45,7 +45,7 @@ class StoreNotices extends AbstractBlock { return; } - $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); + $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, array(), array( 'extra_classes' ) ); return sprintf( '
%2$s
',