[wp-trac] [WordPress Trac] #11515: Admin needs standardized way of handling messages (notices) displayed to the user
WordPress Trac
noreply at wordpress.org
Fri Jun 6 00:59:12 UTC 2014
#11515: Admin needs standardized way of handling messages (notices) displayed to
the user
------------------------------------------+-----------------------------
Reporter: filosofo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Administration | Version: 3.0
Severity: normal | Resolution:
Keywords: error-message admin-messages | Focuses:
------------------------------------------+-----------------------------
Comment (by iandunn):
+1
It sucks for plugins to have to
[https://meta.trac.wordpress.org/changeset/654/ jump through hoops] to
make notices persist through the post/get/redirect process.
In some of my personal projects I've been doing essentially the same thing
as Konstantin's patch. One minor tweak that I like is to
[https://github.com/iandunn/admin-notice-helper/blob/master/admin-notice-
helper.php#L91 group the types of messages into the same div], so that
they stack cleaner. It looks better than having 2 separate divs when you
end up with 2 errors on the same page.
One problem I ran into in my version was that duplicate messages could be
added, so I had my `enqueue()` method [https://github.com/iandunn/admin-
notice-helper/blob/master/admin-notice-helper.php#L79 only add new ones if
an identical one didn't already exist]. It's been awhile since I wrote
that, but IIRC, the duplicate messages were often added by hook callbacks
that were fired multiple times.
Making the notice expire after 30 seconds makes me feel a bit uneasy,
although I can't think of a great use case for extending it. Perhaps if
there's a redirect and the user's connection craps out, and it takes them
a few minutes (or hours) to get back online; it'd be good if the notice
was still waiting for them when they got back. Probably a pretty rare edge
case, but it'd be easy to extend it and I don't think it'd hurt anything.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/11515#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list