WordPress.org

Make WordPress Core

Ticket #19691: admin_messages_hook-2.diff

File admin_messages_hook-2.diff, 6.6 KB (added by mikeschinkel, 6 years ago)

Adds 'admin_messages' hook.

  • wp-admin/users.php

     
    382382        </div>
    383383<?php endif;
    384384
     385$messages = apply_filters( 'admin_messages', $messages );
     386
    385387if ( ! empty($messages) ) {
    386388        foreach ( $messages as $msg )
    387389                echo $msg;
  • wp-admin/edit-comments.php

     
    220220                        }
    221221                }
    222222
     223                $messages = apply_filters( 'admin_messages', $messages );
     224
    223225                echo '<div id="moderated" class="updated"><p>' . implode( "<br/>\n", $messages ) . '</p></div>';
    224226        }
    225227}
  • wp-admin/edit-tags.php

     
    268268        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?>
    269269</h2>
    270270
    271 <?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
    272 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
    273 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
    274 endif; ?>
     271<?php
     272if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ):
     273        $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
     274        $message = $messages[$msg];
     275else:
     276        $message = false;
     277endif;
     278$message_list = apply_filters( 'admin_messages', array( $message ) );
     279if ( 0 != count( $message_list ) ):?>
     280<div id="message" class="updated"><p><?php
     281        foreach( $message_list as $message )
     282                echo $message;
     283?></p></div>
     284<?php endif; ?>
    275285<div id="ajax-response"></div>
    276286
    277287<form class="search-form" action="" method="get">
  • wp-admin/user-new.php

     
    231231        </div>
    232232<?php endif;
    233233
     234$messages = apply_filters( 'admin_messages', $messages );
     235
    234236if ( ! empty( $messages ) ) {
    235237        foreach ( $messages as $msg )
    236238                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
  • wp-admin/upload.php

     
    220220        $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
    221221}
    222222
    223 if ( !empty($message) ) { ?>
    224 <div id="message" class="updated"><p><?php echo $message; ?></p></div>
     223$message_list = apply_filters( 'admin_messages', empty( $message ) ? array() : array( $message ) );
     224
     225if ( 0 != count( $message_list ) ) { ?>
     226        <div id="message" class="updated"><p><?php
     227        foreach( $message_list as $msg )
     228                echo $msg;
     229?></p></div>
    225230<?php } ?>
    226231
    227232<?php $wp_list_table->views(); ?>
  • wp-admin/network/site-new.php

     
    112112<?php screen_icon('ms-admin'); ?>
    113113<h2 id="add-new-site"><?php _e('Add New Site') ?></h2>
    114114<?php
     115$messages = apply_filters( 'admin_messages', $messages );
    115116if ( ! empty( $messages ) ) {
    116117        foreach ( $messages as $msg )
    117118                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
  • wp-admin/network/site-info.php

     
    113113?>
    114114</h3>
    115115<?php
     116$messages = apply_filters( 'admin_messages', $messages );
    116117if ( ! empty( $messages ) ) {
    117118        foreach ( $messages as $msg )
    118119                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
  • wp-admin/network/site-settings.php

     
    104104</h3>
    105105<?php
    106106if ( ! empty( $messages ) ) {
     107        $messages = apply_filters( 'admin_messages', $messages );
    107108        foreach ( $messages as $msg )
    108109                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
    109110} ?>
  • wp-admin/network/user-new.php

     
    7474<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
    7575<?php
    7676if ( ! empty( $messages ) ) {
     77        $messages = apply_filters( 'admin_messages', $messages );
    7778        foreach ( $messages as $msg )
    7879                echo '<div id="message" class="updated"><p>' . $msg . '</p></div>';
    7980}
  • wp-admin/nav-menus.php

     
    473473        <?php screen_icon(); ?>
    474474        <h2><?php esc_html_e('Menus'); ?></h2>
    475475        <?php
     476
     477        $messages = apply_filters( 'admin_messages', $messages );
     478
    476479        foreach( $messages as $message ) :
    477480                echo $message . "\n";
    478481        endforeach;
  • wp-admin/widgets.php

     
    318318<?php screen_icon(); ?>
    319319<h2><?php echo esc_html( $title ); ?></h2>
    320320
    321 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
    322 <div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
    323 <?php } ?>
    324 <?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
    325 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>
    326 <?php } ?>
     321<?php
     322if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) {
     323        $message_list = apply_filters( 'admin_messages', array( $messages[$_GET['message']] ) );
     324} else {
     325        $message_list = array();
     326}
     327if ( 0 != count( $message_list ) ) {
     328        echo '<div id="message" class="updated"><p>';
     329        foreach( $message_list as $msg )
     330                echo $msg;
     331        echo '</p></div>';
     332}
     333if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) {
     334        $error_list = apply_filters( 'error_messages', array( $errors[$_GET['error']] ) );
     335} else {
     336        $error_list = array();
     337}
     338if ( 0 != count( $message_list ) ) {
     339        echo '<div id="message" class="error"><p>';
     340        foreach( $error_list as $error_msg )
     341                echo $error_msg;
     342        echo '</p></div>';
     343}
     344?>
    327345
    328346<?php do_action( 'widgets_admin_page' ); ?>
    329347