diff --git a/wp-admin/includes/admin-filters.php b/wp-admin/includes/admin-filters.php index 240474949c..7f94480d02 100644 --- a/wp-admin/includes/admin-filters.php +++ b/wp-admin/includes/admin-filters.php @@ -56,6 +56,9 @@ add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 ); +add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); +add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); + add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 679b9ac5d6..21baaceaf5 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -936,3 +936,83 @@ function wp_page_reload_on_back_button_js() { $hash, + 'newemail' => $value, + ); + update_option( 'adminhash', $new_admin_email ); + + $switched_locale = switch_to_locale( get_user_locale() ); + + /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ + $email_text = __( 'Howdy ###USERNAME###, + +You recently requested to have the administration email address on +your site changed. + +If this is correct, please click on the following link to change it: +###ADMIN_URL### + +You can safely ignore and delete this email if you do not want to +take this action. + +This email has been sent to ###EMAIL### + +Regards, +All at ###SITENAME### +###SITEURL###' ); + + /** + * Filters the text of the email sent when a change of site admin email address is attempted. + * + * The following strings have a special meaning and will get replaced dynamically: + * ###USERNAME### The current user's username. + * ###ADMIN_URL### The link to click on to confirm the email change. + * ###EMAIL### The proposed new site admin email address. + * ###SITENAME### The name of the site. + * ###SITEURL### The URL to the site. + * + * @since MU (3.0.0) + * @since 4.9.0 This filter is no longer Multisite specific. + * + * @param string $email_text Text in the email. + * @param array $new_admin_email { + * Data relating to the new site admin email address. + * + * @type string $hash The secure hash used in the confirmation link URL. + * @type string $newemail The proposed new site admin email address. + * } + */ + $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email ); + + $current_user = wp_get_current_user(); + $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); + $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content ); + $content = str_replace( '###EMAIL###', $value, $content ); + $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content ); + $content = str_replace( '###SITEURL###', home_url(), $content ); + + wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content ); + + if ( $switched_locale ) { + restore_previous_locale(); + } +} diff --git a/wp-admin/includes/ms-admin-filters.php b/wp-admin/includes/ms-admin-filters.php index 62785505a0..e8952e15b3 100644 --- a/wp-admin/includes/ms-admin-filters.php +++ b/wp-admin/includes/ms-admin-filters.php @@ -16,10 +16,6 @@ add_action( 'network_admin_notices', 'new_user_email_admin_notice' ); add_action( 'admin_page_access_denied', '_access_denied_splash', 99 ); -add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); - -add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); - // Site Hooks. add_action( 'wpmueditblogaction', 'upload_space_setting' ); diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 4c19b5685b..15f7848bef 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -265,83 +265,6 @@ function wpmu_delete_user( $id ) { return true; } -/** - * Send a confirmation request email when a change of site admin email address is attempted. - * - * The new site admin address will not become active until confirmed. - * - * @since 3.0.0 - * - * @param string $old_value The old site admin email address. - * @param string $value The proposed new site admin email address. - */ -function update_option_new_admin_email( $old_value, $value ) { - if ( $value == get_option( 'admin_email' ) || !is_email( $value ) ) - return; - - $hash = md5( $value. time() .mt_rand() ); - $new_admin_email = array( - 'hash' => $hash, - 'newemail' => $value - ); - update_option( 'adminhash', $new_admin_email ); - - $switched_locale = switch_to_locale( get_user_locale() ); - - /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */ - $email_text = __( 'Howdy ###USERNAME###, - -You recently requested to have the administration email address on -your site changed. - -If this is correct, please click on the following link to change it: -###ADMIN_URL### - -You can safely ignore and delete this email if you do not want to -take this action. - -This email has been sent to ###EMAIL### - -Regards, -All at ###SITENAME### -###SITEURL###' ); - - /** - * Filters the text of the email sent when a change of site admin email address is attempted. - * - * The following strings have a special meaning and will get replaced dynamically: - * ###USERNAME### The current user's username. - * ###ADMIN_URL### The link to click on to confirm the email change. - * ###EMAIL### The proposed new site admin email address. - * ###SITENAME### The name of the site. - * ###SITEURL### The URL to the site. - * - * @since MU (3.0.0) - * - * @param string $email_text Text in the email. - * @param array $new_admin_email { - * Data relating to the new site admin email address. - * - * @type string $hash The secure hash used in the confirmation link URL. - * @type string $newemail The proposed new site admin email address. - * } - */ - $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email ); - - $current_user = wp_get_current_user(); - $content = str_replace( '###USERNAME###', $current_user->user_login, $content ); - $content = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash='.$hash ) ), $content ); - $content = str_replace( '###EMAIL###', $value, $content ); - $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content ); - $content = str_replace( '###SITEURL###', network_home_url(), $content ); - - wp_mail( $value, sprintf( __( '[%s] New Admin Email Address' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ), $content ); - - if ( $switched_locale ) { - restore_previous_locale(); - } -} - /** * Check whether a site has used its allotted upload space. * diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 834f02733a..0fcdde3518 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -56,20 +56,25 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
class="regular-text code" /> | |||
class="regular-text code" />
@@ -77,11 +82,36 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
want your site home page to be different from your WordPress installation directory.' ); ?> |
|||
- | - | ++ |
+ The new address will not become active until confirmed.' ); ?> + +
+
+
+' . esc_html( $new_admin_email ) . '' + ); + printf( + ' %2$s', + esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), + __( 'Cancel' ) + ); + ?> + |
- |
- The new address will not become active until confirmed.' ) ?> - -
-
-
-' . esc_html( $new_admin_email ) . '' - ); - printf( - ' %2$s', - esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), - __( 'Cancel' ) - ); -?> - |
-