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

Add usages of `wp_admin_notice()` and `wp_get_admin_notice()` on `.notice-[type]` in the root level of `/wp-admin/`. Ongoing task to implement new function across core.

Props costdev, joedolson.
See #57791.

git-svn-id: https://develop.svn.wordpress.org/trunk@56570 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson
2023-09-14 00:52:45 +00:00
parent 96a7954ee6
commit 3cefc7c7ff
20 changed files with 434 additions and 225 deletions

View File

@@ -200,36 +200,57 @@ switch ( $action ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
<div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
<?php endif; ?>
<?php
if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) :
$message = '<strong>' . __( 'Important:' ) . '</strong> ' . __( 'This user has super admin privileges.' );
wp_admin_notice(
$message,
array(
'type' => 'info',
)
);
endif;
<?php if ( isset( $_GET['updated'] ) ) : ?>
<div id="message" class="updated notice is-dismissible">
<?php if ( IS_PROFILE_PAGE ) : ?>
<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
<?php else : ?>
<p><strong><?php _e( 'User updated.' ); ?></strong></p>
<?php endif; ?>
<?php if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
<p><a href="<?php echo esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
<?php endif; ?>
</div>
<?php endif; ?>
if ( isset( $_GET['updated'] ) ) :
if ( IS_PROFILE_PAGE ) :
$message = '<strong>' . __( 'Profile updated.' ) . '</strong>';
else :
$message = '<strong>' . __( 'User updated.' ) . '</strong>';
endif;
if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
$message .= '<a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ) . '">' . __( '&larr; Go to Users' ) . '</a>';
endif;
wp_admin_notice(
$message,
array(
'id' => 'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
)
);
endif;
<?php if ( isset( $_GET['error'] ) ) : ?>
<div class="notice notice-error">
<?php if ( 'new-email' === $_GET['error'] ) : ?>
<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
if ( isset( $_GET['error'] ) ) :
$message = '';
if ( 'new-email' === $_GET['error'] ) :
$message = __( 'Error while saving the new email address. Please try again.' );
endif;
wp_admin_notice(
$message,
array(
'type' => 'error',
)
);
endif;
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
if ( isset( $errors ) && is_wp_error( $errors ) ) {
?>
<div class="error">
<p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
</div>
<?php endif; ?>
<?php
}
?>
<div class="wrap" id="profile-page">
<h1 class="wp-heading-inline">
@@ -802,11 +823,17 @@ switch ( $action ) {
<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
</div>
<?php else : ?>
<div class="notice notice-error inline">
<p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
</div>
<?php endif; ?>
<?php
else :
wp_admin_notice(
__( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
array(
'type' => 'error',
'additional_classes' => array( 'inline' ),
)
);
endif;
?>
<div class="application-passwords-list-table-wrapper">
<?php