#44941 closed enhancement (fixed)
Support `warning` and `info` type notices in settings errors
Reported by: | desrosj | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Administration | Keywords: | has-screenshots has-patch has-dev-note |
Focuses: | administration | Cc: |
Description
The add_settings_error()
only supports error
and updated
admin notices. These should also be supported for scenarios where error or updated are not appropriate.
Attachments (3)
Change History (18)
This ticket was mentioned in Slack in #core-privacy by desrosj. View the logs.
6 years ago
This ticket was mentioned in Slack in #core-privacy by javorszky. View the logs.
6 years ago
This ticket was mentioned in Slack in #design by karmatosed. View the logs.
5 years ago
#6
@
5 years ago
- Keywords ui-feedback removed
This was discussed in this week's triage meeting. Thank you for the work done here, looks great and removing feedback keyword.
#7
@
5 years ago
In my patch 44941.2.diff, I removed the CSS part because notices should use the existing .notice-*
styles. See #44640.
#8
@
5 years ago
- Milestone changed from Awaiting Review to 5.3
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#10
follow-up:
↓ 11
@
5 years ago
- Keywords needs-dev-note added
Minor: worth noting the changes in [45814] break plugins that are (with good intent) passing a proper CSS class. For example, if a plugin passes notice-error
, the CSS class printed out will now be notice-notice-error
. Maybe worth considering a quick dev note. See also #44640.
Yes, the previous documentation mentioned Accepts 'error' or 'updated'
but there was nothing in the code to prevent to pass arbitrary class names. Even in the new code there's nothing to prevent it.
Also, one could pass a string like the following:
error my-own-css-class hello world
and actually get the following (spaces are stripped out by sanitize_html_class()
):
notice notice-errormy-own-css-classhelloworld settings-error is-dismissible
#11
in reply to:
↑ 10
@
5 years ago
- Keywords needs-patch added; has-patch removed
- Resolution fixed deleted
- Status changed from closed to reopened
Replying to afercia:
Minor: worth noting the changes in [45814] break plugins that are (with good intent) passing a proper CSS class. For example, if a plugin passes
notice-error
, the CSS class printed out will now benotice-notice-error
. Maybe worth considering a quick dev note. See also #44640.
Good catch, we should only add notice-
if it doesn't already exist, and only to error
, success
, warning
, info
, not other random classes.
Also, one could pass a string like the following:
error my-own-css-class hello world
and actually get the following (spaces are stripped out by
sanitize_html_class()
):
notice notice-errormy-own-css-classhelloworld settings-error is-dismissible
I guess I was a bit overzealous with sanitize_html_class()
, esc_attr()
could be used instead.
Looks like this needs some more work, I don't think we should break backward compatibility here.
#15
@
5 years ago
- Keywords has-dev-note added; needs-dev-note removed
Mentioned in the Miscellaneous Developer Focused Changes dev note for 5.3: https://make.wordpress.org/core/2019/10/15/miscellaneous-developer-focused-changes-in-5-3/
44941.diff uses
.settings-error.warning
and.settings-error.info
to add support for these. Theupdated
anderror
notices are supported with thediv.updated
anddiv.error
selectors, but addingdiv.warning
anddiv.info
to core would probably result in plugin and theme elements unintentionally being styled.If the
div
selectors are preferred, that could maybe go into a major release if accompanied by adev-note
, but that doesn't address all backward compatibility concerns.