[wp-trac] [WordPress Trac] #44082: settings_errors() wraps all notices in p and strong tags

WordPress Trac noreply at wordpress.org
Mon May 14 19:06:59 UTC 2018


#44082: settings_errors() wraps all notices in p and strong tags
-----------------------------+-----------------------------
 Reporter:  johnjamesjacoby  |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 I noticed today that `settings_errors()` wraps every notice in a set of
 `<p>` and `<strong>` tags.

 This is undesirable for a few reasons:

 * Notices should be allowed to use their own formatting (they already are
 everywhere)
 * Many/most core notices that do not use `settings_errors()` are not
 strong, or use `strong` for emphasizing specific parts of a notice

 As a result, almost every plugin is forced to reinvent their own approach
 for putting out admin notices. Core even does this in a bespoke way in
 almost every other admin page, resulting in a bunch of duplication and
 fragmentation of approaches.

 (A quick grep of `.php` files in `wp-admin` with `is-dismissible` in them
 shows 75.)

 ----

 A few ideas:

 * We could use `wpautop()` to wrap each notice to avoid duplicate `<p>`
 tags
 * We could use KSES to only allow certain tags in a notice (not certain
 this is necessary)
 * We could invent a new function for formatting admin area notices in
 places other than settings (which most plugins do already, so something
 they can use is preferable)

 I can also imagine this issue being a smaller part of a larger
 `admin_notices` initiative, but figured I'd at least document this kvetch.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44082>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list