Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Enable new notice styles for all themes #12043

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/js/base/components/notice-banner/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
.wc-forward {
float: right;
color: $gray-800 !important;
background: transparent;
background: transparent !important; // For transparent notice button in Twenty Twenty-One theme.
padding: 0 !important;
margin: 0;
border: 0;
Expand All @@ -70,6 +70,7 @@
background-color: $gray-800;
flex-shrink: 0;
flex-grow: 0;
height: 100%;
}

> .wc-block-components-button {
Expand Down
28 changes: 13 additions & 15 deletions src/Domain/Services/Notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,12 @@ public function __construct( Package $package ) {
}

/**
* Set all hooks related to adding Checkout Draft order functionality to Woo Core. This is only enabled if the user
* is using the new block based cart/checkout.
* Initialize notice hooks.
*/
public function init() {
if ( CartCheckoutUtils::is_cart_block_default() || CartCheckoutUtils::is_checkout_block_default() ) {
add_filter( 'woocommerce_kses_notice_allowed_tags', [ $this, 'add_kses_notice_allowed_tags' ] );
add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );
add_action(
'wp_head',
function() {
// These pages may return notices in ajax responses, so we need the styles to be ready.
if ( is_cart() || is_checkout() ) {
wp_enqueue_style( 'wc-blocks-style' );
}
}
);
}
add_filter( 'woocommerce_kses_notice_allowed_tags', [ $this, 'add_kses_notice_allowed_tags' ] );
add_filter( 'wc_get_template', [ $this, 'get_notices_template' ], 10, 5 );
add_action( 'wp_head', [ $this, 'enqueue_notice_styles' ] );
}

/**
Expand Down Expand Up @@ -101,4 +90,13 @@ public function get_notices_template( $template, $template_name, $args, $templat
}
return $template;
}

/**
* Replaces all notices with the new block based notices.
*
* @return void
*/
public function enqueue_notice_styles() {
wp_enqueue_style( 'wc-blocks-style' );
}
}
Loading