Commit 7e88acf05a for wordpress.org
commit 7e88acf05a4414a64a000fde41cdc6c9fff96300
Author: afercia <afercia@git.wordpress.org>
Date: Wed Oct 7 13:41:52 2026 +0000
Users: Improve the usability and consistency of the admin notices related to email changes.
- Renders an admin 'info' notice in the General Settings page when changing the administration email.
- The notice is similar to the one already rendered in the User Profile when changing the user email.
- Both the notices at the top are now rendered after the 'settings saved' one.
- For both notices:
- The 'Cancel' link text is now a more meaningful 'Cancel request'.
- The 'Cancel request' link is now rendered also in the admin notice at the top.
- The notices in the middle of the page are now of type 'info' instead of 'success'. This is consistent with the notices at the top. Also, the notices content is informative and the previous 'success' type was not appropriate.
- Changes the text of one of the notices by updating the text 'admin email' to 'administration email' for consistency with the related setting label.
- Improves the redirect links by using `add_query_arg()`.
Developed in https://github.com/WordPress/wordpress-develop/pull/13927
Fixes #66173.
Built from https://develop.svn.wordpress.org/trunk@64228
git-svn-id: http://core.svn.wordpress.org/trunk@63379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/admin-filters.php b/wp-admin/includes/admin-filters.php
index e1943da439..0fec0867cf 100644
--- a/wp-admin/includes/admin-filters.php
+++ b/wp-admin/includes/admin-filters.php
@@ -121,7 +121,6 @@ add_action( 'install_themes_pre_theme-information', 'install_theme_information'
add_action( 'admin_init', 'default_password_nag_handler' );
add_action( 'admin_notices', 'default_password_nag' );
-add_action( 'admin_notices', 'new_user_email_admin_notice' );
add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 );
diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php
index c1efa0c063..1e6e00ea70 100644
--- a/wp-admin/options-general.php
+++ b/wp-admin/options-general.php
@@ -22,6 +22,9 @@ $parent_file = 'options-general.php';
/* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */
$timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
+$new_admin_email = get_option( 'new_admin_email' );
+$pending_new_admin_email = $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email;
+
add_action( 'admin_head', 'options_general_add_js' );
$options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' .
@@ -67,6 +70,36 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
<div class="wrap">
<h1><?php echo esc_html( $title ); ?></h1>
+<?php
+if ( isset( $_GET['admin_email_updated'] ) ) {
+ $message = '<strong>' . __( 'Administration email updated.' ) . '</strong>';
+ wp_admin_notice(
+ $message,
+ array(
+ 'id' => 'message',
+ 'dismissible' => true,
+ 'type' => 'success',
+ )
+ );
+}
+
+$pending_admin_email_cancel_request_link = sprintf(
+ ' <a href="%1$s">%2$s</a>',
+ esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
+ _x( 'Cancel request', 'admin email change' )
+);
+
+if ( $pending_new_admin_email ) {
+ $message = sprintf(
+ /* translators: %s: New administration email address. */
+ __( 'The administration email address has not been updated yet. Please check the inbox at %s for a confirmation email.' ),
+ '<code>' . esc_html( $new_admin_email ) . '</code>'
+ );
+ $message .= $pending_admin_email_cancel_request_link;
+ wp_admin_notice( $message, array( 'type' => 'info' ) );
+}
+?>
+
<form method="post" action="options.php" novalidate="novalidate">
<?php settings_fields( 'general' ); ?>
@@ -266,22 +299,18 @@ if ( ! is_multisite() ) {
<td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
<p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this, an email will be sent to your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
<?php
-$new_admin_email = get_option( 'new_admin_email' );
-if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) {
+if ( $pending_new_admin_email ) {
$pending_admin_email_message = sprintf(
- /* translators: %s: New admin email. */
- __( 'There is a pending change of the admin email to %s.' ),
+ /* translators: %s: New administration email address. */
+ __( 'There is a pending change of the administration email to %s.' ),
'<code>' . esc_html( $new_admin_email ) . '</code>'
);
- $pending_admin_email_message .= sprintf(
- ' <a href="%1$s">%2$s</a>',
- esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
- __( 'Cancel' )
- );
+ $pending_admin_email_message .= $pending_admin_email_cancel_request_link;
wp_admin_notice(
$pending_admin_email_message,
array(
- 'additional_classes' => array( 'updated', 'inline' ),
+ 'type' => 'info',
+ 'additional_classes' => array( 'inline' ),
)
);
}
diff --git a/wp-admin/options.php b/wp-admin/options.php
index 9413eb3b1a..8f065f6447 100644
--- a/wp-admin/options.php
+++ b/wp-admin/options.php
@@ -57,7 +57,7 @@ if ( ! current_user_can( $capability ) ) {
// Handle admin email change requests.
if ( ! empty( $_GET['adminhash'] ) ) {
$new_admin_details = get_option( 'adminhash' );
- $redirect = 'options-general.php?updated=false';
+ $redirect = add_query_arg( array( 'updated' => 'false' ), 'options-general.php' );
if ( is_array( $new_admin_details )
&& hash_equals( $new_admin_details['hash'], $_GET['adminhash'] )
@@ -66,7 +66,13 @@ if ( ! empty( $_GET['adminhash'] ) ) {
update_option( 'admin_email', $new_admin_details['newemail'] );
delete_option( 'adminhash' );
delete_option( 'new_admin_email' );
- $redirect = 'options-general.php?updated=true';
+ $redirect = add_query_arg(
+ array(
+ 'updated' => 'true',
+ 'admin_email_updated' => 'true',
+ ),
+ 'options-general.php',
+ );
}
wp_redirect( admin_url( $redirect ) );
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index f76cbd2bce..cdd442fe98 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -266,9 +266,15 @@ switch ( $action ) {
<div class="wrap" id="profile-page">
<h1 class="wp-heading-inline">
- <?php echo esc_html( $title ); ?>
+ <?php echo esc_html( $title ); ?>
</h1>
+ <?php
+ if ( IS_PROFILE_PAGE ) {
+ new_user_email_admin_notice();
+ }
+ ?>
+
<?php if ( ! IS_PROFILE_PAGE ) : ?>
<?php if ( current_user_can( 'create_users' ) ) : ?>
<a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add User' ); ?></a>
@@ -596,12 +602,13 @@ switch ( $action ) {
$pending_change_message .= sprintf(
' <a href="%1$s">%2$s</a>',
esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
- __( 'Cancel' )
+ _x( 'Cancel request', 'user email change' )
);
wp_admin_notice(
$pending_change_message,
array(
- 'additional_classes' => array( 'updated', 'inline' ),
+ 'type' => 'info',
+ 'additional_classes' => array( 'inline' ),
)
);
endif;
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index d97fab076f..3bcfcb6102 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -1266,6 +1266,7 @@ function wp_removable_query_args() {
'activate',
'activated',
'admin_email_remind_later',
+ 'admin_email_updated',
'approved',
'core-major-auto-updates-saved',
'deactivate',
diff --git a/wp-includes/user.php b/wp-includes/user.php
index 352dcf357b..1d0523cfc9 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -4017,14 +4017,20 @@ All at ###SITENAME###
function new_user_email_admin_notice() {
global $pagenow;
- if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) ) {
- $email = get_user_meta( get_current_user_id(), '_new_email', true );
+ if ( 'profile.php' === $pagenow ) {
+ $current_user_id = get_current_user_id();
+ $email = get_user_meta( $current_user_id, '_new_email', true );
if ( $email ) {
$message = sprintf(
/* translators: %s: New email address. */
__( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ),
'<code>' . esc_html( $email['newemail'] ) . '</code>'
);
+ $message .= sprintf(
+ ' <a href="%1$s">%2$s</a>',
+ esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user_id . '_new_email' ), 'dismiss-' . $current_user_id . '_new_email' ) ),
+ _x( 'Cancel request', 'user email change' ),
+ );
wp_admin_notice( $message, array( 'type' => 'info' ) );
}
}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 756d5971d6..d167552f57 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-alpha-64227';
+$wp_version = '7.2-alpha-64228';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.