Make WordPress Core


Ignore:
Timestamp:
10/07/2026 01:40:25 PM (8 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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        );
Note: See TracChangeset for help on using the changeset viewer.