[wp-trac] [WordPress Trac] #31233: Dismissable admin notices

WordPress Trac noreply at wordpress.org
Fri Mar 13 15:48:48 UTC 2015


#31233: Dismissable admin notices
----------------------------------------------+------------------
 Reporter:  ryan                              |       Owner:
     Type:  task (blessed)                    |      Status:  new
 Priority:  normal                            |   Milestone:  4.2
Component:  Administration                    |     Version:  4.1
 Severity:  normal                            |  Resolution:
 Keywords:  make-flow has-patch dev-feedback  |     Focuses:  ui
----------------------------------------------+------------------
Changes (by valendesigns):

 * keywords:  make-flow => make-flow has-patch dev-feedback


Comment:

 The last patch had a minor UI issue where it would cover a bit of text in
 long messages. I fixed that by prepending the link and floating it right
 instead of appending and making it absolute positioned.

 Once I fixed that, I saw a potential for making the whole thing much
 better. My implementation in patch [attachment:31233.2.diff] includes
 hide, but also adds dismiss with cookie support. The dismiss functionality
 is only activated when the notice has `data-dismiss="true"` set. This way
 we could go beyond per page load and actually have legitimate dismissible
 notices, not just hide them.

 I also made the cookie expiration extensible with a data attribute.
 Instead of the cookie expiring after the session you can set that number
 using `data-expires="60"`, for example. Then the notice will only be
 dismissed for a minute.

 Something I think is important is the ability to turn the default hide
 behavior off on a per notice basis. So if you add `data-hide="false"` that
 notice will always display. I still have some backwards compatibility
 concerns with adding this to every single notice. What about all the
 plugins and themes that already have this type of functionality? Well,
 those notices would be really ugly and confusing. So at the very least, we
 need to be able to turn this off. I suggest we also post on the Make blog
 about any change to notices, and give plugin & theme developers time to
 update their code.

 Here are some notice examples to further demonstrate my changes.

 {{{
 function ticket_31233_admin_notices() {
         ?>
         <div class="updated">
                 <p><?php _e( 'This notice can be hidden for a single page
 load, and is the default behavior.' ); ?></p>
         </div>
         <div class="updated" data-hide="false">
                 <p><?php _e( 'This notice cannot be hidden.' ); ?></p>
         </div>
         <div class="updated" data-dismiss="true">
                 <p><?php _e( 'This notice can be dismissed for the entire
 session.' ); ?></p>
         </div>
         <div class="updated" data-dismiss="true" data-expires="60">
                 <p><?php _e( 'This notice can be dismissed for 60
 seconds.' ); ?></p>
         </div>
         <?php
 }
 add_action( 'admin_notices', 'ticket_31233_admin_notices' );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/31233#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list