Add missing classnames for WP blocks
This commit is contained in:
parent
9c58f198cf
commit
13ea1466c1
|
@ -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(
|
||||
'<div class="wp-block-add-to-cart-form wc-block-add-to-cart-form %1$s %2$s %3$s" style="%4$s">%5$s</div>',
|
||||
esc_attr( $classes_and_styles['classes'] ),
|
||||
esc_attr( $classname ),
|
||||
esc_attr( $product_classname ),
|
||||
esc_attr( $classes_and_styles['styles'] ),
|
||||
'<div %1$s>%2$s</div>',
|
||||
$wrapper_attributes,
|
||||
$product
|
||||
);
|
||||
|
||||
|
|
|
@ -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(
|
||||
'<div class="wc-block-components-product-image wc-block-grid__product-image %1$s" style="%2$s">
|
||||
%3$s
|
||||
'<div %1$s>
|
||||
%2$s
|
||||
</div>',
|
||||
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 ),
|
||||
|
|
|
@ -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(
|
||||
'<div class="wc-block-components-product-rating wc-block-grid__product-rating %1$s %2$s" style="%3$s">
|
||||
%4$s
|
||||
'<div %1$s>
|
||||
%2$s
|
||||
</div>',
|
||||
esc_attr( $text_align_styles_and_classes['class'] ?? '' ),
|
||||
esc_attr( $styles_and_classes['classes'] ),
|
||||
esc_attr( $styles_and_classes['styles'] ?? '' ),
|
||||
$wrapper_attributes,
|
||||
$rating_html
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
'<div class="wc-block-components-product-rating-counter wc-block-grid__product-rating-counter %1$s %2$s" style="%3$s">
|
||||
%4$s
|
||||
'<div %1$s>
|
||||
%2$s
|
||||
</div>',
|
||||
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 '';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
'<div class="wc-block-components-product-rating wc-block-grid__product-rating %1$s %2$s" style="%3$s">
|
||||
%4$s
|
||||
'<div %1$s>
|
||||
%2$s
|
||||
</div>',
|
||||
esc_attr( $text_align_styles_and_classes['class'] ?? '' ),
|
||||
esc_attr( $styles_and_classes['classes'] ),
|
||||
esc_attr( $styles_and_classes['styles'] ?? '' ),
|
||||
$wrapper_attributes,
|
||||
$rating_html
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue