| | 939 | |
| | 940 | /** |
| | 941 | * Send email to old email address on change site admin email |
| | 942 | * @param string $old_email |
| | 943 | * @param string $new_email |
| | 944 | * @param string $option_name |
| | 945 | * @since 4.8.0 |
| | 946 | */ |
| | 947 | function send_email_on_admin_email_change( $old_email, $new_email, $option_name ) { |
| | 948 | |
| | 949 | /** |
| | 950 | * Filters whether to send the admin email change. |
| | 951 | * |
| | 952 | * @since 4.8.0 |
| | 953 | * |
| | 954 | * |
| | 955 | * @param bool $send Whether to send the email. |
| | 956 | * @param array $old_email The original admin email. |
| | 957 | * @param array $new_email The updated admin email. |
| | 958 | * |
| | 959 | */ |
| | 960 | $send_admin_email_change_email = apply_filters( 'send_admin_email_change_email', true, $old_email, $new_email ); |
| | 961 | if ( $send_admin_email_change_email ) { |
| | 962 | /* translators: Do not translate ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| | 963 | $email_change_text = __( 'Hi, |
| | 964 | |
| | 965 | This notice confirms your site admin e-mail has been changed on ###SITENAME###. |
| | 966 | Your new site admin e-mail is now "###NEWEMAIL###" |
| | 967 | |
| | 968 | Regards, |
| | 969 | All at ###SITENAME### |
| | 970 | ###SITEURL###' ); |
| | 971 | |
| | 972 | $email_change_email = array( |
| | 973 | 'to' => $old_email, |
| | 974 | /* translators: Site admin email change notification email subject. 1: Site name */ |
| | 975 | 'subject' => __( '[%s] Notice of Admin Email Change' ), |
| | 976 | 'message' => $email_change_text, |
| | 977 | 'headers' => '', |
| | 978 | ); |
| | 979 | // get blog name |
| | 980 | $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
| | 981 | |
| | 982 | /** |
| | 983 | * Filters the contents of the email sent when the site admin email is change |
| | 984 | * |
| | 985 | * |
| | 986 | * @since 4.8.0 |
| | 987 | * |
| | 988 | * @param array $email_change_email { |
| | 989 | * Used to build wp_mail(). |
| | 990 | * @type string $to The intended recipients. |
| | 991 | * @type string $subject The subject of the email. |
| | 992 | * @type string $message The content of the email. |
| | 993 | * The following strings have a special meaning and will get replaced dynamically: |
| | 994 | * - ###NEWEMAIL### The admin email in case this was unexpected. |
| | 995 | * - ###SITENAME### The name of the site. |
| | 996 | * - ###SITEURL### The URL to the site. |
| | 997 | * @type string $headers Headers. |
| | 998 | * } |
| | 999 | * @param array $old_email The original email |
| | 1000 | * @param array $new_email The updated email. |
| | 1001 | */ |
| | 1002 | $email_change_email = apply_filters( 'admin_email_change_email', $email_change_email, $old_email, $new_email ); |
| | 1003 | |
| | 1004 | $email_change_email['message'] = str_replace( '###NEWEMAIL###', $new_email, $email_change_email[ 'message' ] ); |
| | 1005 | $email_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $email_change_email['message'] ); |
| | 1006 | $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); |
| | 1007 | |
| | 1008 | wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $blog_name ), $email_change_email['message'], $email_change_email['headers'] ); |
| | 1009 | } |
| | 1010 | } |