Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow usage of block notice templates when using classic themes (#45164)
* Allow block notice templates in classic themes * Add changefile(s) from automation for the following project(s): woocommerce-blocks, woocommerce * Fix e2e constants file * Improve inline comments * Add filter and enhance e2e tests * Adjust test names * Adress PHP lint errors * Adress PHP lint errors * Adress PHP lint errors --------- Co-authored-by: github-actions <github-actions@github.com>
- Loading branch information
1 parent
59635fb
commit a738357
Showing
31 changed files
with
568 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
plugins/woocommerce-blocks/tests/e2e/bin/themes/storefront-child/style.css
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...commerce-blocks/tests/e2e/bin/themes/storefront-child__block-notices-filter/functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
add_filter( 'woocommerce_use_block_notices_in_classic_theme', '__return_true' ); |
4 changes: 4 additions & 0 deletions
4
.../woocommerce-blocks/tests/e2e/bin/themes/storefront-child__block-notices-filter/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Storefront Child (Block Notices by filter) | ||
Template: storefront | ||
*/ |
4 changes: 4 additions & 0 deletions
4
...oocommerce-blocks/tests/e2e/bin/themes/storefront-child__block-notices-template/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Storefront Child (Block Notices by template) | ||
Template: storefront | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...commerce-blocks/tests/e2e/bin/themes/storefront-child__classic-notices-template/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Storefront Child (Classic Notices by template) | ||
Template: storefront | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
plugins/woocommerce-blocks/tests/e2e/bin/themes/twentytwentyfour-child/style.css
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...ce-blocks/tests/e2e/bin/themes/twentytwentyfour-child__block-notices-filter/functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
add_filter( 'woocommerce_use_block_notices_in_classic_theme', '__return_false' ); |
4 changes: 4 additions & 0 deletions
4
...mmerce-blocks/tests/e2e/bin/themes/twentytwentyfour-child__block-notices-filter/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Twenty Twenty-Four Child (Block Notices by filter) | ||
Template: twentytwentyfour | ||
*/ |
4 changes: 4 additions & 0 deletions
4
...erce-blocks/tests/e2e/bin/themes/twentytwentyfour-child__block-notices-template/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Twenty Twenty-Four Child (Block Notices by template) | ||
Template: twentytwentyfour | ||
*/ |
51 changes: 51 additions & 0 deletions
51
...e/bin/themes/twentytwentyfour-child__block-notices-template/woocommerce/notices/error.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* Show error messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/error.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://docs.woocommerce.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 8.5.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( empty( $notices ) || ! is_array( $notices ) ) { | ||
return; | ||
} | ||
|
||
$multiple = count( $notices ) > 1; | ||
|
||
?> | ||
|
||
<div class="wc-block-components-notice-banner is-error" role="alert" <?php echo $multiple ? '' : wc_get_notice_data_attr( $notices[0] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"> | ||
<path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path> | ||
</svg> | ||
<div class="wc-block-components-notice-banner__content"> | ||
<?php if ( $multiple ) { ?> | ||
<p class="wc-block-components-notice-banner__summary"><?php esc_html_e( 'The following problems were found:', 'woocommerce' ); ?></p> | ||
<ul> | ||
<?php foreach ( $notices as $notice ) : ?> | ||
<li<?php echo wc_get_notice_data_attr( $notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>> | ||
BLOCK ERROR NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php | ||
} else { | ||
echo 'BLOCK ERROR NOTICE: ' . wc_kses_notice( $notices[0]['notice'] ); | ||
} | ||
?> | ||
</div> | ||
</div> | ||
<?php |
37 changes: 37 additions & 0 deletions
37
.../bin/themes/twentytwentyfour-child__block-notices-template/woocommerce/notices/notice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Show info messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/notice.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://docs.woocommerce.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 8.5.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( ! $notices ) { | ||
return; | ||
} | ||
|
||
?> | ||
|
||
<?php foreach ( $notices as $notice ) : ?> | ||
<div class="wc-block-components-notice-banner is-info"<?php echo wc_get_notice_data_attr( $notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> role="alert"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"> | ||
<path d="M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"></path> | ||
</svg> | ||
<div class="wc-block-components-notice-banner__content"> | ||
BLOCK INFO NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</div> | ||
</div> | ||
<?php endforeach; ?> |
37 changes: 37 additions & 0 deletions
37
...bin/themes/twentytwentyfour-child__block-notices-template/woocommerce/notices/success.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
/** | ||
* Show success messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://docs.woocommerce.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 8.5.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( ! $notices ) { | ||
return; | ||
} | ||
|
||
?> | ||
|
||
<?php foreach ( $notices as $notice ) : ?> | ||
<div class="wc-block-components-notice-banner is-success"<?php echo wc_get_notice_data_attr( $notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> role="alert"> | ||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"> | ||
<path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path> | ||
</svg> | ||
<div class="wc-block-components-notice-banner__content"> | ||
BLOCK SUCCESS NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</div> | ||
</div> | ||
<?php endforeach; ?> |
4 changes: 4 additions & 0 deletions
4
...ce-blocks/tests/e2e/bin/themes/twentytwentyfour-child__classic-notices-template/style.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Theme Name: Twenty Twenty-Four Child (Classic Notices by template) | ||
Template: twentytwentyfour | ||
*/ |
34 changes: 34 additions & 0 deletions
34
...bin/themes/twentytwentyfour-child__classic-notices-template/woocommerce/notices/error.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Show error messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/error.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://woo.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 3.9.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( ! $notices ) { | ||
return; | ||
} | ||
|
||
?> | ||
|
||
<ul class="woocommerce-error" role="alert"> | ||
<?php foreach ( $notices as $notice ) : ?> | ||
<li<?php echo wc_get_notice_data_attr( $notice ); ?>> | ||
CLASSIC ERROR NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> |
32 changes: 32 additions & 0 deletions
32
...in/themes/twentytwentyfour-child__classic-notices-template/woocommerce/notices/notice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Show messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/notice.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://woo.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 3.9.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( ! $notices ) { | ||
return; | ||
} | ||
|
||
?> | ||
|
||
<?php foreach ( $notices as $notice ) : ?> | ||
<div class="woocommerce-info"<?php echo wc_get_notice_data_attr( $notice ); ?>> | ||
CLASSIC INFO NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</div> | ||
<?php endforeach; ?> |
32 changes: 32 additions & 0 deletions
32
...n/themes/twentytwentyfour-child__classic-notices-template/woocommerce/notices/success.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* Show messages | ||
* | ||
* This template can be overridden by copying it to yourtheme/woocommerce/notices/success.php. | ||
* | ||
* HOWEVER, on occasion WooCommerce will need to update template files and you | ||
* (the theme developer) will need to copy the new files to your theme to | ||
* maintain compatibility. We try to do this as little as possible, but it does | ||
* happen. When this occurs the version of the template file will be bumped and | ||
* the readme will list any important changes. | ||
* | ||
* @see https://woo.com/document/template-structure/ | ||
* @package WooCommerce\Templates | ||
* @version 3.9.0 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
if ( ! $notices ) { | ||
return; | ||
} | ||
|
||
?> | ||
|
||
<?php foreach ( $notices as $notice ) : ?> | ||
<div class="woocommerce-message"<?php echo wc_get_notice_data_attr( $notice ); ?> role="alert"> | ||
CLASSIC SUCCESS NOTICE: <?php echo wc_kses_notice( $notice['notice'] ); ?> | ||
</div> | ||
<?php endforeach; ?> |
Oops, something went wrong.