WordPress.org

Make WordPress Core

Ticket #19691: admin_messages_hook.diff

File admin_messages_hook.diff, 5.7 KB (added by mikeschinkel, 6 years ago)

Adds 'admin_messages' and 'admin_message' hooks.

  • 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

     
    269269</h2>
    270270
    271271<?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?>
    272 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div>
     272<?php $message = apply_filters( 'admin_message', $messages[$msg], $messages, $_REQUEST['message'] ); ?>
     273<div id="message" class="updated"><p><?php echo $message; ?></p></div>
    273274<?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
    274275endif; ?>
    275276<div id="ajax-response"></div>
  • 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$message = apply_filters( 'admin_message', $message, $messages, $_GET['message'] );
     224
    223225if ( !empty($message) ) { ?>
    224226<div id="message" class="updated"><p><?php echo $message; ?></p></div>
    225227<?php } ?>
  • 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/edit.php

     
    260260        unset($_REQUEST['undeleted']);
    261261}
    262262
     263$messages = apply_filters( 'admin_messages', $messages );
     264
    263265if ( $messages )
    264266        echo join( ' ', $messages );
    265267unset( $messages );
  • wp-admin/widgets.php

     
    319319<h2><?php echo esc_html( $title ); ?></h2>
    320320
    321321<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
    322 <div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>
     322<?php   $message = apply_filters( 'admin_message', $messages[$_GET['message']], $messages, $_GET['message'] ); ?>
     323<div id="message" class="updated"><p><?php echo $message; ?></p></div>
    323324<?php } ?>
    324325<?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?>
    325326<div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div>