Make WordPress Core


Ignore:
Timestamp:
08/17/2023 09:01:17 PM (7 months ago)
Author:
joedolson
Message:

Administration: Apply admin notice functions in multisite.

Use wp_get_admin_notice and wp_admin_notice to handle multisite settings notices.

Props costdev.
See #57791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/site-users.php

    r55618 r56409  
    235235
    236236if ( isset( $_GET['update'] ) ) :
     237    $message = '';
     238    $type    = 'error';
     239
    237240    switch ( $_GET['update'] ) {
    238241        case 'adduser':
    239             echo '<div id="message" class="notice notice-success is-dismissible"><p>' . __( 'User added.' ) . '</p></div>';
     242            $type    = 'success';
     243            $message = __( 'User added.' );
    240244            break;
    241245        case 'err_add_member':
    242             echo '<div id="message" class="notice notice-error  is-dismissible"><p>' . __( 'User is already a member of this site.' ) . '</p></div>';
     246            $message = __( 'User is already a member of this site.' );
    243247            break;
    244248        case 'err_add_fail':
    245             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'User could not be added to this site.' ) . '</p></div>';
     249            $message = __( 'User could not be added to this site.' );
    246250            break;
    247251        case 'err_add_notfound':
    248             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>';
     252            $message = __( 'Enter the username of an existing user.' );
    249253            break;
    250254        case 'promote':
    251             echo '<div id="message" class="notice notice-success is-dismissible"><p>' . __( 'Changed roles.' ) . '</p></div>';
     255            $type    = 'success';
     256            $message = __( 'Changed roles.' );
    252257            break;
    253258        case 'err_promote':
    254             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'Select a user to change role.' ) . '</p></div>';
     259            $message = __( 'Select a user to change role.' );
    255260            break;
    256261        case 'remove':
    257             echo '<div id="message" class="notice notice-success is-dismissible"><p>' . __( 'User removed from this site.' ) . '</p></div>';
     262            $type    = 'success';
     263            $message = __( 'User removed from this site.' );
    258264            break;
    259265        case 'err_remove':
    260             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'Select a user to remove.' ) . '</p></div>';
     266            $message = __( 'Select a user to remove.' );
    261267            break;
    262268        case 'newuser':
    263             echo '<div id="message" class="notice notice-success is-dismissible"><p>' . __( 'User created.' ) . '</p></div>';
     269            $type    = 'success';
     270            $message = __( 'User created.' );
    264271            break;
    265272        case 'err_new':
    266             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'Enter the username and email.' ) . '</p></div>';
     273            $message = __( 'Enter the username and email.' );
    267274            break;
    268275        case 'err_new_dup':
    269             echo '<div id="message" class="notice notice-error is-dismissible"><p>' . __( 'Duplicated username or email address.' ) . '</p></div>';
     276            $message = __( 'Duplicated username or email address.' );
    270277            break;
    271278    }
     279
     280    wp_admin_notice(
     281        $message,
     282        array(
     283            'type'        => $type,
     284            'dismissible' => true,
     285            'id'          => 'message',
     286        )
     287    );
    272288endif;
    273289?>
Note: See TracChangeset for help on using the changeset viewer.