From 768f51f60c308a06492dcda163b80c1c3ff6ebb9 Mon Sep 17 00:00:00 2001
From: joedolson
Date: Thu, 14 Sep 2023 02:15:17 +0000
Subject: [PATCH] Administration: Use `wp_admin_notice()` for `.updated`.
Add usages of `wp_admin_notice()` and `wp_get_admin_notice()` on `.updated` in the root level of `/wp-admin/`. Ongoing task to implement new function across core.
Props costdev, joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56573
git-svn-id: http://core.svn.wordpress.org/trunk@56085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
wp-admin/edit-comments.php | 10 ++-
wp-admin/edit-link-form.php | 15 ++++-
wp-admin/edit.php | 10 ++-
wp-admin/link-manager.php | 12 +++-
wp-admin/nav-menus.php | 66 ++++++++++++++++---
wp-admin/options-general.php | 38 +++++------
wp-admin/plugins.php | 119 ++++++++++++++++++-----------------
wp-admin/themes.php | 97 ++++++++++++++++++++--------
wp-admin/upload.php | 63 ++++++++++++++-----
wp-admin/user-edit.php | 41 ++++++------
wp-admin/user-new.php | 9 ++-
wp-admin/users.php | 102 ++++++++++++++++++++++++++----
wp-admin/widgets-form.php | 28 ++++++---
wp-includes/version.php | 2 +-
14 files changed, 430 insertions(+), 182 deletions(-)
diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php
index ffc1d58d8c..a39aa701de 100644
--- a/wp-admin/edit-comments.php
+++ b/wp-admin/edit-comments.php
@@ -411,9 +411,13 @@ if ( isset( $_REQUEST['approved'] )
}
}
- printf(
- '',
- implode( "
\n", $messages )
+ wp_admin(
+ implode( "
\n", $messages ),
+ array(
+ 'id' => 'moderated',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
);
}
}
diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php
index f63f1a39b0..1bbb32d3a6 100644
--- a/wp-admin/edit-link-form.php
+++ b/wp-admin/edit-link-form.php
@@ -91,9 +91,18 @@ echo esc_html( $title );
-
-
-
+ 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
+}
+?>
- ID, '_new_email', true ); ?>
- user_email && $profile_user->ID === $current_user->ID ) : ?>
-
-
- ' . esc_html( $new_email['newemail'] ) . ''
- );
- printf(
- ' %2$s',
- esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
- __( 'Cancel' )
- );
- ?>
-
-
-
+ ID, '_new_email', true );
+ if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
+
+ $pending_change_message = sprintf(
+ /* translators: %s: New email. */
+ __( 'There is a pending change of your email to %s.' ),
+ '' . esc_html( $new_email['newemail'] ) . '
'
+ );
+ $pending_change_message .= sprintf(
+ ' %2$s',
+ esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
+ __( 'Cancel' )
+ );
+ wp_admin_notice(
+ $pending_change_message,
+ array(
+ 'additional_classes' => array( 'updated', 'inline' ),
+ )
+ );
+ endif;
+ ?>
diff --git a/wp-admin/user-new.php b/wp-admin/user-new.php
index 901f2b7352..b516f4f460 100644
--- a/wp-admin/user-new.php
+++ b/wp-admin/user-new.php
@@ -396,7 +396,14 @@ endif;
if ( ! empty( $messages ) ) {
foreach ( $messages as $msg ) {
- echo '';
+ wp_admin_notice(
+ $msg,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
}
}
?>
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 97b96a7b1a..717f487c5c 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -610,11 +610,18 @@ switch ( $wp_list_table->current_action() ) {
/* translators: %s: Number of users. */
$message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
}
- $messages[] = '' . sprintf( $message, number_format_i18n( $delete_count ) ) . '
';
+ $message = sprintf( $message, number_format_i18n( $delete_count ) );
+ $messages[] = wp_get_admin_notice(
+ $message,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'add':
$message = __( 'New user created.' );
-
$user_id = isset( $_GET['id'] ) ? $_GET['id'] : false;
if ( $user_id && current_user_can( 'edit_user', $user_id ) ) {
$message .= sprintf(
@@ -630,7 +637,14 @@ switch ( $wp_list_table->current_action() ) {
);
}
- $messages[] = '';
+ $messages[] = wp_get_admin_notice(
+ $message,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'resetpassword':
$reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0;
@@ -640,25 +654,89 @@ switch ( $wp_list_table->current_action() ) {
/* translators: %s: Number of users. */
$message = _n( 'Password reset links sent to %s user.', 'Password reset links sent to %s users.', $reset_count );
}
- $messages[] = '' . sprintf( $message, number_format_i18n( $reset_count ) ) . '
';
+ $message = sprintf( $message, number_format_i18n( $reset_count ) );
+ $messages[] = wp_get_admin_notice(
+ $message,
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'promote':
- $messages[] = '' . __( 'Changed roles.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'Changed roles.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'err_admin_role':
- $messages[] = '' . __( 'The current user’s role must have user editing capabilities.' ) . '
';
- $messages[] = '' . __( 'Other user roles have been changed.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'The current user’s role must have user editing capabilities.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
+ $messages[] = wp_get_admin_notice(
+ __( 'Other user roles have been changed.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'err_admin_del':
- $messages[] = '' . __( 'You cannot delete the current user.' ) . '
';
- $messages[] = '' . __( 'Other users have been deleted.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'You cannot delete the current user.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
+ $messages[] = wp_get_admin_notice(
+ __( 'Other users have been deleted.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'remove':
- $messages[] = '' . __( 'User removed from this site.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'User removed from this site.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated', 'fade' ),
+ 'dismissible' => true,
+ )
+ );
break;
case 'err_admin_remove':
- $messages[] = '' . __( 'You cannot remove the current user.' ) . '
';
- $messages[] = '' . __( 'Other users have been removed.' ) . '
';
+ $messages[] = wp_get_admin_notice(
+ __( 'You cannot remove the current user.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
+ $messages[] = wp_get_admin_notice(
+ __( 'Other users have been removed.' ),
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'updated', 'fade' ),
+ 'dismissible' => true,
+ )
+ );
break;
}
endif;
diff --git a/wp-admin/widgets-form.php b/wp-admin/widgets-form.php
index aa01798856..0c88a8559f 100644
--- a/wp-admin/widgets-form.php
+++ b/wp-admin/widgets-form.php
@@ -403,14 +403,28 @@ $nonce = wp_create_nonce( 'widgets-access' );
-
-
-
-
-
-
-
'message',
+ 'additional_classes' => array( 'updated' ),
+ 'dismissible' => true,
+ )
+ );
+}
+if ( isset( $_GET['error'] ) && isset( $errors[ $_GET['error'] ] ) ) {
+ wp_admin_notice(
+ $errors[ $_GET['error'] ],
+ array(
+ 'id' => 'message',
+ 'additional_classes' => array( 'error' ),
+ 'dismissible' => true,
+ )
+ );
+}
+
/**
* Fires before the Widgets administration page content loads.
*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index be78d73df6..7a9eaef592 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '6.4-alpha-56572';
+$wp_version = '6.4-alpha-56573';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.