-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Replace hardcoded notices with the correct wp_print_notice function #37514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hi @coreymckrill, Apart from reviewing the code changes, please make sure to review the testing instructions as well. You can follow this guide to find out what good testing instructions should look like: |
Test Results SummaryCommit SHA: e8fcfbb
To view the full API test report, click here. To view the full E2E test report, click here. To view all test reports, visit the WooCommerce Test Reports Dashboard. |
opr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and the notices work for me, and the code changes look mostly OK, I added some comments that might need action, but also might not so I will approve and let you decide whether to action them.
plugins/woocommerce/templates/myaccount/lost-password-confirmation.php
Outdated
Show resolved
Hide resolved
| echo '<p class="cart-empty woocommerce-info">' . wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) ) . '</p>'; | ||
| echo '<div class="cart-empty">' . | ||
| wc_print_notice( | ||
| wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need esc_html__ or is it safe to skip because it's wrapped in wp_kses_post?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escaping should come last so I think its ok to let KSES deal with this one. The filter could also return HTML.
|
Thanks @opr I fixed up those template versions which would have been blocking. Escaping is left as it was before for the |
opr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mikejolley that's great now.
e1a510f to
e78e04f
Compare
coreymckrill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mikejolley, this all looks good! Testing instructions worked as expected, and it appears that no translation strings were changed 👍
Just one tweak needs to be made to some e2e tests (see below) and then this should be good to go.
| echo '<p class="cart-empty woocommerce-info">' . wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) ) . '</p>'; | ||
| echo '<div class="cart-empty">'; | ||
| wc_print_notice( wp_kses_post( apply_filters( 'wc_empty_cart_message', __( 'Your cart is currently empty.', 'woocommerce' ) ) ), 'notice' ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment | ||
| echo '</div>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## trunk #37514 +/- ##
==========================================
- Coverage 51.6% 51.5% -0.0%
- Complexity 17260 17261 +1
==========================================
Files 429 429
Lines 79928 79957 +29
==========================================
+ Hits 41213 41215 +2
- Misses 38715 38742 +27
|
|
@coreymckrill Those tests are updated but there are seemingly unrelated e2e fails. Can you take a look please? |
|
🤔 @mikejolley I think the e2e's are still failing because of the three related empty cart tests (example). Given the following assertion: I suspect the reason this is failing may be because Playwright expects that the |
06aad2c to
b800a42
Compare
|
@coreymckrill I don't think its that because |
|
|
coreymckrill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e2e tests passing now 👍
All Submissions:
The contribution guidelines do not cover changelog entry creation—I had an error from a pre-commit hook when pushing.
Changes proposed in this Pull Request:
When working on woocommerce/woocommerce-blocks#8659 we realised several of the notices rendered by WooCommerce core across several frontend template files did not use the notice function helpers (
wp_print_notice) or templates, and were instead hardcoded.This PR replaces hardcoded notices with the correct functions and makes it possible to modify the notices via template overrides.
Additionally, a small modification to
wp_print_noticewas added so that the notice could be returned as a string instead of rendered. This was to make it more flexible. e.g.How to test the changes in this Pull Request:
These instructions cover how to test notices that were changed.
?s=noresultsto the URL. Confirm you see the "No products were found matching your selection" notice.Other information:
pnpm --filter=<project> changelog add?FOR PR REVIEWER ONLY: