Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Cc @pattonwebz |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Honestly, I would just remove testing for this and remove the workarounds I had to introduce to support this passed notice type.
But:
It was introduced in https://core.trac.wordpress.org/changeset/45873 to account for an edge case reported by... myself. Still, I'd consider to remove it also because wp_get_admin_notice() doesn't accept a type string that contains spaces.
Open to feedback.
| if ( 'updated' === $details['type'] ) { | ||
| $details['type'] = 'success'; | ||
| // Backward compatibility for passed types that may wrongly contain `notice-`. | ||
| $type = str_replace( 'notice-', '', trim( $details['type'] ) ); |
There was a problem hiding this comment.
Passed types should no longer contain notice- as wp_get_admin_notice() already adds this prefix.
There was a problem hiding this comment.
Could this accidentally remove notice- from the unintended class? What if someone passs in a type like 'error my-notice-is-awesome hello world'?
| $css_class = sprintf( | ||
| 'notice %s settings-error is-dismissible', | ||
| esc_attr( $details['type'] ) | ||
| esc_attr( $details['code'] ), |
There was a problem hiding this comment.
Minor: This escaping is redundant. It is already handled by wp_get_admin_notice().
| esc_attr( $details['code'] ), | |
| $details['code'], |
| $additional_classes = explode( ' ', $type . ' settings-error' ); | ||
| // Set the type to empty string. | ||
| $type = ''; | ||
|
|
| if ( str_contains( $type, ' ' ) ) { | ||
| // Use ths substrings as additional classes. | ||
| $additional_classes = explode( ' ', $type . ' settings-error' ); | ||
| // Set the type to empty string. |
There was a problem hiding this comment.
This is obvious 😄
| // Set the type to empty string. |
| if ( 'updated' === $details['type'] ) { | ||
| $details['type'] = 'success'; | ||
| // Backward compatibility for passed types that may wrongly contain `notice-`. | ||
| $type = str_replace( 'notice-', '', trim( $details['type'] ) ); |
There was a problem hiding this comment.
Could this accidentally remove notice- from the unintended class? What if someone passs in a type like 'error my-notice-is-awesome hello world'?
|
Currently, this PR introduces a change in the behavior for potential custom notice types. This is inherently the behavior of |
33891a0 to
9c14839
Compare
|
I addressed the backward compatibility issue in a hopefully better way and added more test cases. It covers cases when the This should cover the previous behavior. |
32664c6 to
8ecee8f
Compare
joedolson
left a comment
There was a problem hiding this comment.
A minor change suggestion in a comment, for improved clarity. Otherwise, I think this looks good.
| * classes are rendered in the default order determined by `wp_admin_notice()`. | ||
| * This includes the old type `updated`. Instead, anything else e.g. | ||
| * custom notice types or strings with spaces is now passed as | ||
| * additional_classes and appended to the end of the string, |
There was a problem hiding this comment.
This makes it sound like $additional_classes is a string, when it's an array. I think you should limit the comment to addressing how custom classes are handled here, and not address how they will be handled once they're inside wp_admin_notices().
8ecee8f to
7df6fa0
Compare
edc789e to
8ce4b17
Compare
The amdin notices rendered in the Settings pages use their own function to echo the notices, which is a little legacy. Today, Core provides a standardized way to render the admin notices by the means of `wp_admin_notice()`. - Refactors `settings_errors()` to use `wp_admin_notice()` internally. - Expands the related tests. Added bonus: The Settings pages notices will now fire the some hooks and filters fired by `wp_admin_notice()`, e.g. `wp_admin_notice` and `wp_admin_notice_markup`, which is a necessary preparation for #50486. Developed in #13669 Props afercia, westonruter, joedolson. See #50486. Fixes #66161. git-svn-id: https://develop.svn.wordpress.org/trunk@63943 602fd350-edb4-49c9-b593-d223f7449a82
The amdin notices rendered in the Settings pages use their own function to echo the notices, which is a little legacy. Today, Core provides a standardized way to render the admin notices by the means of `wp_admin_notice()`. - Refactors `settings_errors()` to use `wp_admin_notice()` internally. - Expands the related tests. Added bonus: The Settings pages notices will now fire the some hooks and filters fired by `wp_admin_notice()`, e.g. `wp_admin_notice` and `wp_admin_notice_markup`, which is a necessary preparation for #50486. Developed in WordPress/wordpress-develop#13669 Props afercia, westonruter, joedolson. See #50486. Fixes #66161. Built from https://develop.svn.wordpress.org/trunk@63943 git-svn-id: http://core.svn.wordpress.org/trunk@63109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/66161
Use of AI Tools
None
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.