Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/wp-admin/includes/admin-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
49 changes: 39 additions & 10 deletions src/wp-admin/options-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' .
Expand Down Expand Up @@ -67,6 +70,36 @@
<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' ); ?>

Expand Down Expand Up @@ -266,22 +299,18 @@ class="<?php echo esc_attr( $classes_for_button ); ?>"
<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' ),
)
);
}
Expand Down
10 changes: 8 additions & 2 deletions src/wp-admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] )
Expand All @@ -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 ) );
Expand Down
13 changes: 10 additions & 3 deletions src/wp-admin/user-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,15 @@

<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>
Expand Down Expand Up @@ -596,12 +602,13 @@
$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;
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 8 additions & 2 deletions src/wp-includes/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.' ),
'<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' ) );
}
}
Expand Down
Loading