[wp-trac] [WordPress Trac] #57791: Create function to output admin notices
WordPress Trac
noreply at wordpress.org
Mon Mar 13 17:23:50 UTC 2023
#57791: Create function to output admin notices
-------------------------------------------------+-------------------------
Reporter: joedolson | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Administration | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests dev- | Focuses:
feedback | administration
-------------------------------------------------+-------------------------
Comment (by costdev):
> @joedolson The logic in your update doesn't totally match the original,
since in the original the foreach loops over all messages and then echos
the whole output, vs. outputting each message as it comes.
> That said, I can't see any particular reason that would matter.
I noticed the above and also came to the same conclusion. 🙂
A quick check on the `wp_get_admin_notice()` vs `wp_admin_notice()`
approach. The PR introduces a new action: `wp_admin_notice`.
With the return/output approach, this would either:
- Be fired when creating an admin notice, which may not be desired.
- Be fired only when `wp_admin_notice()` is called, which wouldn't catch
all admin notices.
Example:
With the PR as it stands, implementing `wp_admin_notice()` in
`settings_errors()` would fire the `wp_admin_notice` action X times.
However, if `settings_errors()` instead used a `wp_get_admin_notice()`
function, concatenating the results, then outputting, it wouldn't fire the
`wp_admin_notice` action at all.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/57791#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list