-
Notifications
You must be signed in to change notification settings - Fork 0
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
Enhancement/update success error messages to wp admin notices #85
base: develop
Are you sure you want to change the base?
Enhancement/update success error messages to wp admin notices #85
Conversation
Lint project and fix errors
Only admin notices should be displayed here
This better explains the functions purpose and will prevent confusion in the future. Updated mailchimp_sf_frontend_msg comments to explain how WP admin notices are used in the WP admin
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.
I've highlighted some areas that I think would benefit from additional scrutiny. If anyone would like to request changes I would be happy to make them =).
@@ -253,7 +253,7 @@ function mailchimp_sf_request_handler() { | |||
if ( ! headers_sent() ) { // just in case... | |||
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT', true, 200 ); | |||
} | |||
echo wp_kses_post( mailchimp_sf_global_msg() ); | |||
echo wp_kses_post( mailchimp_sf_frontend_msg() ); |
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.
Renamed mailchimp_sf_global_msg
to mailchimp_sf_frontend_msg
to reflect new role of this msg function.
Flagging for extra scrutiny.
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.
I'm fine with the rename though I guess not sure if it's accurate? Seems that function still outputs admin messages, while I'd expect a function called frontend message to only output messages on the front-end, not admin?
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.
Hey @dkotter, thanks for calling this out. Are you referring to the mailchimp_sf_frontend_msg
call in mailchimp_sf_request_handler
at line 256? I believe this fetches the error messages accumulated during the BE validation handling.
There's some validation on the accounts creation page in the admin, but that looks like it's being handled via JS validation in assets/js/admin.js
.
I double checked the codebase for other areas where mailchimp_sf_request_handler
might be used in the admin, but I couldn't find any. Please correct me if I'm wrong. I'd be happy to revert the same or update the codebase.
@@ -253,7 +253,7 @@ function mailchimp_sf_request_handler() { | |||
if ( ! headers_sent() ) { // just in case... | |||
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT', true, 200 ); | |||
} | |||
echo wp_kses_post( mailchimp_sf_global_msg() ); | |||
echo wp_kses_post( mailchimp_sf_frontend_msg() ); |
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.
I'm fine with the rename though I guess not sure if it's accurate? Seems that function still outputs admin messages, while I'd expect a function called frontend message to only output messages on the front-end, not admin?
I don't think this needs to be called out in the readme. |
Description of the Change
On the plugin settings page, replace the custom Mailchimp UI for admin notices to the standard WP admin notices API
Drawbacks
Possible regressions
While I've tested for all of these scenarios and fixed any issues I've found the following items are the most likely regressions.
Closes #62
How to test the Change
WP Admin messages
A video recording can be made on request for any of the testing items below.
I've documented all of the possible testing scenarios that I found while making the changes, but due to the extensive list of areas to test I recommend making a note of any items that are too difficult or time consuming to efficiently test. We can then look at the items that were not tested and decide on a plan.
For example, testing the error message for an invalid Mailchimp API token would require finding a way to fail the OAuth flow while still navigating to the plugin settings page. It might be better to talk about items like that and brainstorm easier ways of ensuring regression proof code, such as relying on the OAuth test in
/tests/cypress/e2e/connect.test.js
or extending it.Success message
Settings page URL:
/wp-admin/admin.php?page=mailchimp_sf_options
Error message
FE messages
FE messages should remain unchanged
Success Messages
Submit the form after filling out all required fields to trigger the success message
Error Messages
Submit the form without entering any details to trigger the error message
The following scenarios will also throw errors on the FE
Changelog Entry
Credits
Props @MaxwellGarceau
Checklist: