diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index 5337cc02c88c9..8f77f605fac93 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -120,7 +120,6 @@ 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/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index c1efa0c063c58..1e6e00ea703d8 100644 --- a/src/wp-admin/options-general.php +++ b/src/wp-admin/options-general.php @@ -22,6 +22,9 @@ /* 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 = '

' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '

' . @@ -67,6 +70,36 @@

+' . __( 'Administration email updated.' ) . ''; + wp_admin_notice( + $message, + array( + 'id' => 'message', + 'dismissible' => true, + 'type' => 'success', + ) + ); +} + +$pending_admin_email_cancel_request_link = sprintf( + ' %2$s', + 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.' ), + '' . esc_html( $new_admin_email ) . '' + ); + $message .= $pending_admin_email_cancel_request_link; + wp_admin_notice( $message, array( 'type' => 'info' ) ); +} +?> +
@@ -266,22 +299,18 @@ class=""

The new address will not become active until confirmed.' ); ?>

' . esc_html( $new_admin_email ) . '' ); - $pending_admin_email_message .= sprintf( - ' %2$s', - 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/src/wp-admin/options.php b/src/wp-admin/options.php index 9413eb3b1a93b..8f065f64473e6 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -57,7 +57,7 @@ // 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 @@ 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/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 9a31f13e58d29..b27dcac8eec90 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -266,9 +266,15 @@

- +

+ + @@ -596,12 +602,13 @@ $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' ) + _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/src/wp-includes/functions.php b/src/wp-includes/functions.php index 393f50a3aad58..2227da2458708 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -1264,6 +1264,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/src/wp-includes/user.php b/src/wp-includes/user.php index 92d091165525b..f466de798c3d6 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -4015,14 +4015,20 @@ function send_confirmation_on_profile_email( $user_id = 0 ) { 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.' ), '' . esc_html( $email['newemail'] ) . '' ); + $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' ) ), + _x( 'Cancel request', 'user email change' ), + ); wp_admin_notice( $message, array( 'type' => 'info' ) ); } }