From be17f843b6905af0eaa62aed1a7e148861e53793 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 17 Sep 2024 12:30:22 +0100 Subject: [PATCH] Add missing `wp-block-` classnames to order confirmation blocks, Store Notices, and Breadcrumbs (#51380) * Add missing wp-block-x classname to order confirmation blocks * Use get_block_wrapper_attributes for store notices block * Breadcrumbs and notices * Changelog --- .../add-missing-wp-block-classnames-49739 | 4 ++++ .../src/Blocks/BlockTypes/Breadcrumbs.php | 12 +++++++----- .../AbstractOrderConfirmationBlock.php | 5 +++-- .../src/Blocks/BlockTypes/StoreNotices.php | 14 ++++++-------- 4 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 plugins/woocommerce/changelog/add-missing-wp-block-classnames-49739 diff --git a/plugins/woocommerce/changelog/add-missing-wp-block-classnames-49739 b/plugins/woocommerce/changelog/add-missing-wp-block-classnames-49739 new file mode 100644 index 00000000000..dc4c7059a56 --- /dev/null +++ b/plugins/woocommerce/changelog/add-missing-wp-block-classnames-49739 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Added missing wp-block- classes to order confirmation, store notices, and breadcrumb blocks. diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php b/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php index dc25d2258bd..fb0e0b1cc0e 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/Breadcrumbs.php @@ -34,14 +34,16 @@ class Breadcrumbs extends AbstractBlock { return; } - $classname = $attributes['className'] ?? ''; $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); return sprintf( - '
%4$s
', - esc_attr( $classes_and_styles['classes'] ), - esc_attr( $classname ), - esc_attr( $classes_and_styles['styles'] ), + '
%2$s
', + get_block_wrapper_attributes( + array( + 'class' => 'wc-block-breadcrumbs woocommerce ' . esc_attr( $classes_and_styles['classes'] ), + 'style' => $classes_and_styles['styles'], + ) + ), $breadcrumb ); } diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/OrderConfirmation/AbstractOrderConfirmationBlock.php b/plugins/woocommerce/src/Blocks/BlockTypes/OrderConfirmation/AbstractOrderConfirmationBlock.php index 4887dd04e30..66b263dbe82 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/OrderConfirmation/AbstractOrderConfirmationBlock.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/OrderConfirmation/AbstractOrderConfirmationBlock.php @@ -55,11 +55,12 @@ abstract class AbstractOrderConfirmationBlock extends AbstractBlock { } return $block_content ? sprintf( - '
%3$s
', + '
%3$s
', esc_attr( trim( $classname ) ), esc_attr( $classes_and_styles['styles'] ), $block_content, - esc_attr( $this->block_name ) + esc_attr( $this->block_name ), + esc_attr( $this->namespace ) ) : ''; } diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php b/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php index c9c20d21548..9addff1a630 100644 --- a/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php +++ b/plugins/woocommerce/src/Blocks/BlockTypes/StoreNotices.php @@ -45,17 +45,15 @@ class StoreNotices extends AbstractBlock { return; } - $classname = isset( $attributes['className'] ) ? $attributes['className'] : ''; $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); - if ( isset( $attributes['align'] ) ) { - $classname .= " align{$attributes['align']}"; - } - return sprintf( - '
%3$s
', - esc_attr( $classes_and_styles['classes'] ), - esc_attr( $classname ), + '
%2$s
', + get_block_wrapper_attributes( + array( + 'class' => 'wc-block-store-notices woocommerce ' . esc_attr( $classes_and_styles['classes'] ), + ) + ), wc_kses_notice( $notices ) ); }