Opened 10 years ago
Closed 10 years ago
#30199 closed enhancement (duplicate)
Add handling of a admin notice type "warning" to the WP admin.
Reported by: | wedi | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.1 |
Component: | Administration | Keywords: | |
Focuses: | ui, administration | Cc: |
Description
I'd like to suggest adding CSS for an admin notice type warning
to the WP Admin styles to allow nice formating and correct box movement of the following:
- Calling
add_settings_error()
with$type = 'warning'
while working with the Settings API. echo '<div class="warning"><p>A word of warning!</p></div>';
in aadmin_notice
hook callback.
Right now, when a plugin author wants to display a warning message (e.g., a value that looks dangerous or cannot be verified) he has two options of which both are ugly:
- Hijack the update-nag class. Displays a yellow border which is nice for a warning but has different margin/padding assigned and gets not moved below the H2.
- Use an own class, add own css to admin, add own JS to admin to move the box. Works but requires a lot of work for a cosmetic issue and multiple mixed messages of builtin and own types will loose their ordering as
error
andupdated
message boxes get moved when builtin JS runs and own class is either before or after that when cutom JS runs.
The patch attached adds the neccessary CSS and JS as well as documentation for add_settings_error()
.
A different approach to the provided patch would be introducing a new class admin-notice
which gets all message box styles applied and triggers moving by the JS in common.js and error
and updated
are reduced to applying the border colour. This would also reduce some duplicated CSS and allow for adding more box types (e.g. a blue notice box, a green box of envy, ...) easily.
So much text for such a small change... It's my first patch for WordPress so please be kind if I made a mistake. :)
What's missing are the minified versions of the changed CSS and JS files as I don't know the workflow yet.
And the code to reproduce: