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
This commit is contained in:
Mike Jolley 2024-09-17 12:30:22 +01:00 committed by GitHub
parent 66523872f3
commit be17f843b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 15 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Added missing wp-block- classes to order confirmation, store notices, and breadcrumb blocks.

View File

@ -34,14 +34,16 @@ class Breadcrumbs extends AbstractBlock {
return; return;
} }
$classname = $attributes['className'] ?? '';
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
return sprintf( return sprintf(
'<div class="woocommerce wc-block-breadcrumbs %1$s %2$s" style="%3$s">%4$s</div>', '<div %1$s>%2$s</div>',
esc_attr( $classes_and_styles['classes'] ), get_block_wrapper_attributes(
esc_attr( $classname ), array(
esc_attr( $classes_and_styles['styles'] ), 'class' => 'wc-block-breadcrumbs woocommerce ' . esc_attr( $classes_and_styles['classes'] ),
'style' => $classes_and_styles['styles'],
)
),
$breadcrumb $breadcrumb
); );
} }

View File

@ -55,11 +55,12 @@ abstract class AbstractOrderConfirmationBlock extends AbstractBlock {
} }
return $block_content ? sprintf( return $block_content ? sprintf(
'<div class="wc-block-%4$s %1$s" style="%2$s">%3$s</div>', '<div class="wp-block-%5$s-%4$s wc-block-%4$s %1$s" style="%2$s">%3$s</div>',
esc_attr( trim( $classname ) ), esc_attr( trim( $classname ) ),
esc_attr( $classes_and_styles['styles'] ), esc_attr( $classes_and_styles['styles'] ),
$block_content, $block_content,
esc_attr( $this->block_name ) esc_attr( $this->block_name ),
esc_attr( $this->namespace )
) : ''; ) : '';
} }

View File

@ -45,17 +45,15 @@ class StoreNotices extends AbstractBlock {
return; return;
} }
$classname = isset( $attributes['className'] ) ? $attributes['className'] : '';
$classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes ); $classes_and_styles = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes );
if ( isset( $attributes['align'] ) ) {
$classname .= " align{$attributes['align']}";
}
return sprintf( return sprintf(
'<div class="woocommerce wc-block-store-notices %1$s %2$s">%3$s</div>', '<div %1$s>%2$s</div>',
esc_attr( $classes_and_styles['classes'] ), get_block_wrapper_attributes(
esc_attr( $classname ), array(
'class' => 'wc-block-store-notices woocommerce ' . esc_attr( $classes_and_styles['classes'] ),
)
),
wc_kses_notice( $notices ) wc_kses_notice( $notices )
); );
} }