Make WordPress Core


Ignore:
Timestamp:
09/17/2023 03:31:32 PM (5 months ago)
Author:
joedolson
Message:

Administration: Use wp_admin_notice() more in wp-admin/.

Add additional usage of wp_admin_notice() in wp-admin/ on .error and miscellaneous usages previously overlooked.

Follow up to [56408], [56409], [56410], [56518], [56570], [56571], [56572], [56573], [56576], [56589], [56590], [56597], [56599].

Props costdev, joedolson.
See #57791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/user-new.php

    r56573 r56600  
    382382</h1>
    383383
    384 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
    385     <div class="error">
    386         <ul>
    387         <?php
    388         foreach ( $errors->get_error_messages() as $err ) {
    389             echo "<li>$err</li>\n";
    390         }
    391         ?>
    392         </ul>
    393     </div>
    394     <?php
     384<?php
     385if ( isset( $errors ) && is_wp_error( $errors ) ) :
     386    $error_message = '';
     387    foreach ( $errors->get_error_messages() as $err ) {
     388        $error_message .= "<li>$err</li>\n";
     389    }
     390    wp_admin_notice(
     391        '<ul>' . $error_message . '</ul>',
     392        array(
     393            'additional_classes' => array( 'error' ),
     394            'paragraph_wrap'     => false,
     395        )
     396    );
    395397endif;
    396398
     
    409411?>
    410412
    411 <?php if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) : ?>
    412     <div class="error">
    413         <?php
    414         foreach ( $add_user_errors->get_error_messages() as $message ) {
    415             echo "<p>$message</p>";
    416         }
    417         ?>
    418     </div>
    419 <?php endif; ?>
     413<?php
     414if ( isset( $add_user_errors ) && is_wp_error( $add_user_errors ) ) :
     415    $error_message = '';
     416    foreach ( $add_user_errors->get_error_messages() as $message ) {
     417        $error_message .= "<p>$message</p>\n";
     418    }
     419    wp_admin_notice(
     420        $error_message,
     421        array(
     422            'additional_classes' => array( 'error' ),
     423            'paragraph_wrap'     => false,
     424        )
     425    );
     426endif;
     427?>
    420428<div id="ajax-response"></div>
    421429
Note: See TracChangeset for help on using the changeset viewer.