| 142 | |
| 143 | /** |
| 144 | * Send email to old email address on change site admin email |
| 145 | * @param type $old_email |
| 146 | * @param type $new_email |
| 147 | * @param type $option_name |
| 148 | */ |
| 149 | function send_email_on_admin_email_change( $old_email, $new_email, $option_name ) { |
| 150 | |
| 151 | /** |
| 152 | * Filters whether to send the admin email change. |
| 153 | * |
| 154 | * @since 4.8.0 |
| 155 | * |
| 156 | * |
| 157 | * @param bool $send Whether to send the email. |
| 158 | * @param array $old_email The original admin email. |
| 159 | * @param array $new_email The updated admin email. |
| 160 | * |
| 161 | */ |
| 162 | $send_admin_email_change_email = apply_filters( 'send_admin_email_change_email', true, $old_email, $new_email ); |
| 163 | if ( $send_admin_email_change_email ) { |
| 164 | /* translators: Do not translate ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| 165 | $email_change_text = __( 'Hi, |
| 166 | |
| 167 | This notice confirms that your site admin email was changed on ###SITENAME###. |
| 168 | Your new site admin email is: ###NEWEMAIL### |
| 169 | |
| 170 | Regards, |
| 171 | All at ###SITENAME### |
| 172 | ###SITEURL###' ); |
| 173 | |
| 174 | $email_change_email = array( |
| 175 | 'to' => $old_email, |
| 176 | /* translators: Site admin email change notification email subject. 1: Site name */ |
| 177 | 'subject' => __( '[%s] Notice of Admin Email Change' ), |
| 178 | 'message' => $email_change_text, |
| 179 | 'headers' => '', |
| 180 | ); |
| 181 | // get blog name |
| 182 | $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
| 183 | |
| 184 | /** |
| 185 | * Filters the contents of the email sent when the site admin email is change |
| 186 | * |
| 187 | * |
| 188 | * @since 4.8.0 |
| 189 | * |
| 190 | * @param array $email_change_email { |
| 191 | * Used to build wp_mail(). |
| 192 | * @type string $to The intended recipients. |
| 193 | * @type string $subject The subject of the email. |
| 194 | * @type string $message The content of the email. |
| 195 | * The following strings have a special meaning and will get replaced dynamically: |
| 196 | * - ###NEWEMAIL### The admin email in case this was unexpected. |
| 197 | * - ###EMAIL### The old email. |
| 198 | * - ###SITENAME### The name of the site. |
| 199 | * - ###SITEURL### The URL to the site. |
| 200 | * @type string $headers Headers. |
| 201 | * } |
| 202 | * @param array $old_email The original email |
| 203 | * @param array $new_email The updated email. |
| 204 | */ |
| 205 | $email_change_email = apply_filters( 'admin_email_change_email', $email_change_email, $old_email, $new_email ); |
| 206 | |
| 207 | $email_change_email['message'] = str_replace( '###NEWEMAIL###', $new_email, ); |
| 208 | $email_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $email_change_email['message'] ); |
| 209 | $email_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $email_change_email['message'] ); |
| 210 | $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); |
| 211 | |
| 212 | wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $blog_name ), $email_change_email['message'], $email_change_email['headers'] ); |
| 213 | } |
| 214 | } |