diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php index 1237a0e69c5..b5b309320bd 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/AddToCartForm.php @@ -98,12 +98,16 @@ class AddToCartForm extends AbstractBlock { $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $product_classname = $is_descendent_of_single_product_block ? 'product' : ''; + $wrapper_attributes = get_block_wrapper_attributes( + array( + 'class' => 'wc-block-add-to-cart-form ' . esc_attr( $classes_and_styles['classes'] ) . ' ' . esc_attr( $classname ) . ' ' . esc_attr( $product_classname ), + 'style' => esc_attr( $classes_and_styles['styles'] ), + ) + ); + $form = sprintf( - '
%5$s
', - esc_attr( $classes_and_styles['classes'] ), - esc_attr( $classname ), - esc_attr( $product_classname ), - esc_attr( $classes_and_styles['styles'] ), + '
%2$s
', + $wrapper_attributes, $product ); diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php index 9aadea3a948..f7b7719a164 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductImage.php @@ -208,13 +208,19 @@ class ProductImage extends AbstractBlock { $post_id = isset( $block->context['postId'] ) ? $block->context['postId'] : ''; $product = wc_get_product( $post_id ); + $wrapper_attributes = get_block_wrapper_attributes( + array( + 'class' => 'wc-block-components-product-image wc-block-grid__product-image ' . $classes_and_styles['classes'], + 'style' => esc_attr( $classes_and_styles['styles'] ) + ) + ); + if ( $product ) { return sprintf( - '
- %3$s + '
+ %2$s
', - esc_attr( $classes_and_styles['classes'] ), - esc_attr( $classes_and_styles['styles'] ), + $wrapper_attributes, $this->render_anchor( $product, $this->render_on_sale_badge( $product, $parsed_attributes ), diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRating.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRating.php index 1d729677171..64365867a83 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRating.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRating.php @@ -202,13 +202,18 @@ class ProductRating extends AbstractBlock { 10 ); + $wrapper_attributes = get_block_wrapper_attributes( + array( + 'class' => 'wc-block-components-product-rating wc-block-grid__product-rating ' . esc_attr( $text_align_styles_and_classes['class'] ?? '' ) . ' ' . esc_attr( $styles_and_classes['classes'] ), + 'style' => esc_attr( $styles_and_classes['styles'] ?? '' ) + ) + ); + return sprintf( - '
- %4$s + '
+ %2$s
', - esc_attr( $text_align_styles_and_classes['class'] ?? '' ), - esc_attr( $styles_and_classes['classes'] ), - esc_attr( $styles_and_classes['styles'] ?? '' ), + $wrapper_attributes, $rating_html ); } diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingCounter.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingCounter.php index 05dfff98d0f..cb5291628f9 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingCounter.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingCounter.php @@ -132,7 +132,7 @@ class ProductRatingCounter extends AbstractBlock { * @param int $count Total number of ratings. * @return string */ - $filter_rating_html = function( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { + $filter_rating_html = function ( $html, $rating, $count ) use ( $post_id, $product_rating, $product_reviews_count, $is_descendent_of_single_product_block, $is_descendent_of_single_product_template ) { $product_permalink = get_permalink( $post_id ); $reviews_count = $count; $average_rating = $rating; @@ -193,17 +193,21 @@ class ProductRatingCounter extends AbstractBlock { 10 ); + $wrapper_attributes = get_block_wrapper_attributes( + array( + 'class' => 'wc-block-components-product-rating-counter wc-block-grid__product-rating-counter ' . esc_attr( $text_align_styles_and_classes['class'] ?? '' ) . ' ' . esc_attr( $styles_and_classes['classes'] ), + 'style' => esc_attr( $styles_and_classes['styles'] ?? '' ), + ) + ); + return sprintf( - '
- %4$s + '
+ %2$s
', - esc_attr( $text_align_styles_and_classes['class'] ?? '' ), - esc_attr( $styles_and_classes['classes'] ), - esc_attr( $styles_and_classes['styles'] ?? '' ), + $wrapper_attributes, $rating_html ); } return ''; } } - diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingStars.php b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingStars.php index 1f4b1f487be..15a001c6a14 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingStars.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/ProductRatingStars.php @@ -149,13 +149,18 @@ class ProductRatingStars extends AbstractBlock { 10 ); + $wrapper_attributes = get_block_wrapper_attributes( + array( + 'class' => 'wc-block-components-product-rating wc-block-grid__product-rating ' . esc_attr( $text_align_styles_and_classes['class'] ?? '' ) . ' ' . esc_attr( $styles_and_classes['classes'] ), + 'style' => esc_attr( $styles_and_classes['styles'] ?? '' ), + ) + ); + return sprintf( - '
- %4$s + '
+ %2$s
', - esc_attr( $text_align_styles_and_classes['class'] ?? '' ), - esc_attr( $styles_and_classes['classes'] ), - esc_attr( $styles_and_classes['styles'] ?? '' ), + $wrapper_attributes, $rating_html ); }