[wp-trac] [WordPress Trac] #40173: New function wp_admin_notice

WordPress Trac noreply at wordpress.org
Thu Mar 16 15:16:55 UTC 2017


#40173: New function wp_admin_notice
------------------------------+------------------------------
 Reporter:  sebastian.pisula  |       Owner:
     Type:  feature request   |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Administration    |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+------------------------------

Comment (by obenland):

 The  existing API for admin notices shoulders all of that for you already:

 {{{#!php
 <?php
 add_settings_error( 'unique_key', 'warning', __( 'Message' ), 'updated'
 ); // Or 'notice-warning'
 add_settings_error( 'unique_key', 'error',   __( 'Message' ), 'error'
 ); // Or 'notice-error'
 add_settings_error( 'unique_key', 'info',    __( 'Message' ), 'notice-
 info'    );
 add_settings_error( 'unique_key', 'success', __( 'Message' ), 'notice-
 success' );

 add_action( 'all_admin_notices', function() {
      settings_errors( 'unique_key' );
 } );
 }}}

 We could definitely do a better job documenting that behavior however and
 surfacing these possibilities.
 What do you think?

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


More information about the wp-trac mailing list