Make WordPress Core

Changeset 64228


Ignore:
Timestamp:
10/07/2026 01:40:25 PM (3 hours ago)
Author:
afercia
Message:

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.

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/admin-filters.php

    r64120 r64228  
    122122
    123123add_action( 'admin_notices', 'default_password_nag' );
    124 add_action( 'admin_notices', 'new_user_email_admin_notice' );
    125124
    126125add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 );
  • trunk/src/wp-admin/options-general.php

    r63352 r64228  
    2222/* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */
    2323$timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
     24
     25$new_admin_email         = get_option( 'new_admin_email' );
     26$pending_new_admin_email = $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email;
    2427
    2528add_action( 'admin_head', 'options_general_add_js' );
    … …  
    6770<div class="wrap">
    6871<h1><?php echo esc_html( $title ); ?></h1>
     72
     73<?php
     74if ( isset( $_GET['admin_email_updated'] ) ) {
     75        $message = '<strong>' . __( 'Administration email updated.' ) . '</strong>';
     76        wp_admin_notice(
     77                $message,
     78                array(
     79                        'id'          => 'message',
     80                        'dismissible' => true,
     81                        'type'        => 'success',
     82                )
     83        );
     84}
     85
     86$pending_admin_email_cancel_request_link = sprintf(
     87        ' <a href="%1$s">%2$s</a>',
     88        esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
     89        _x( 'Cancel request', 'admin email change' )
     90);
     91
     92if ( $pending_new_admin_email ) {
     93        $message = sprintf(
     94                /* translators: %s: New administration email address. */
     95                __( 'The administration email address has not been updated yet. Please check the inbox at %s for a confirmation email.' ),
     96                '<code>' . esc_html( $new_admin_email ) . '</code>'
     97        );
     98        $message .= $pending_admin_email_cancel_request_link;
     99        wp_admin_notice( $message, array( 'type' => 'info' ) );
     100}
     101?>
    69102
    70103<form method="post" action="options.php" novalidate="novalidate">
    … …  
    267300<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>
    268301<?php
    269 $new_admin_email = get_option( 'new_admin_email' );
    270 if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) {
     302if ( $pending_new_admin_email ) {
    271303        $pending_admin_email_message = sprintf(
    272                 /* translators: %s: New admin email. */
    273                 __( 'There is a pending change of the admin email to %s.' ),
     304                /* translators: %s: New administration email address. */
     305                __( 'There is a pending change of the administration email to %s.' ),
    274306                '<code>' . esc_html( $new_admin_email ) . '</code>'
    275307        );
    276         $pending_admin_email_message .= sprintf(
    277                 ' <a href="%1$s">%2$s</a>',
    278                 esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
    279                 __( 'Cancel' )
    280         );
     308        $pending_admin_email_message .= $pending_admin_email_cancel_request_link;
    281309        wp_admin_notice(
    282310                $pending_admin_email_message,
    283311                array(
    284                         'additional_classes' => array( 'updated', 'inline' ),
     312                        'type'               => 'info',
     313                        'additional_classes' => array( 'inline' ),
    285314                )
    286315        );
  • trunk/src/wp-admin/options.php

    r64046 r64228  
    5858if ( ! empty( $_GET['adminhash'] ) ) {
    5959        $new_admin_details = get_option( 'adminhash' );
    60         $redirect          = 'options-general.php?updated=false';
     60        $redirect          = add_query_arg( array( 'updated' => 'false' ), 'options-general.php' );
    6161
    6262        if ( is_array( $new_admin_details )
    … …  
    6767                delete_option( 'adminhash' );
    6868                delete_option( 'new_admin_email' );
    69                 $redirect = 'options-general.php?updated=true';
     69                $redirect = add_query_arg(
     70                        array(
     71                                'updated'             => 'true',
     72                                'admin_email_updated' => 'true',
     73                        ),
     74                        'options-general.php',
     75                );
    7076        }
    7177
  • trunk/src/wp-admin/user-edit.php

    r64091 r64228  
    267267                <div class="wrap" id="profile-page">
    268268                        <h1 class="wp-heading-inline">
    269                                         <?php echo esc_html( $title ); ?>
     269                                <?php echo esc_html( $title ); ?>
    270270                        </h1>
     271
     272                        <?php
     273                        if ( IS_PROFILE_PAGE ) {
     274                                new_user_email_admin_notice();
     275                        }
     276                        ?>
    271277
    272278                        <?php if ( ! IS_PROFILE_PAGE ) : ?>
    … …  
    597603                                                                        ' <a href="%1$s">%2$s</a>',
    598604                                                                        esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
    599                                                                         __( 'Cancel' )
     605                                                                        _x( 'Cancel request', 'user email change' )
    600606                                                                );
    601607                                                                wp_admin_notice(
    602608                                                                        $pending_change_message,
    603609                                                                        array(
    604                                                                                 'additional_classes' => array( 'updated', 'inline' ),
     610                                                                                'type' => 'info',
     611                                                                                'additional_classes' => array( 'inline' ),
    605612                                                                        )
    606613                                                                );
  • trunk/src/wp-includes/functions.php

    r64163 r64228  
    12671267                'activated',
    12681268                'admin_email_remind_later',
     1269                'admin_email_updated',
    12691270                'approved',
    12701271                'core-major-auto-updates-saved',
  • trunk/src/wp-includes/user.php

    r64163 r64228  
    40184018        global $pagenow;
    40194019
    4020         if ( 'profile.php' === $pagenow && isset( $_GET['updated'] ) ) {
    4021                 $email = get_user_meta( get_current_user_id(), '_new_email', true );
     4020        if ( 'profile.php' === $pagenow ) {
     4021                $current_user_id = get_current_user_id();
     4022                $email           = get_user_meta( $current_user_id, '_new_email', true );
    40224023                if ( $email ) {
    40234024                        $message = sprintf(
    … …  
    40254026                                __( 'Your email address has not been updated yet. Please check your inbox at %s for a confirmation email.' ),
    40264027                                '<code>' . esc_html( $email['newemail'] ) . '</code>'
     4028                        );
     4029                        $message .= sprintf(
     4030                                ' <a href="%1$s">%2$s</a>',
     4031                                esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user_id . '_new_email' ), 'dismiss-' . $current_user_id . '_new_email' ) ),
     4032                                _x( 'Cancel request', 'user email change' ),
    40274033                        );
    40284034                        wp_admin_notice( $message, array( 'type' => 'info' ) );
Note: See TracChangeset for help on using the changeset viewer.