WordPress.org

Make WordPress Core

Ticket #49661: #wp_mailer-v2.patch

File #wp_mailer-v2.patch, 143.8 KB (added by arena, 8 months ago)

v2 of patch

  • wp-admin/includes/misc.php

     
    13021302
    13031303        $switched_locale = switch_to_locale( get_user_locale() );
    13041304
    1305         /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    1306         $email_text = __(
    1307                 'Howdy ###USERNAME###,
     1305        /**
     1306         * Filter removed
     1307         *
     1308         * $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
     1309         *
     1310         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     1311         *
     1312         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1313         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1314         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1315         *
     1316         */
    13081317
     1318        $wp_mail = array(
     1319                'id' => 'new_admin_email',
     1320                'group' => 'admin',
     1321
     1322                'to' => $value,
     1323                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1324                'subject' => __( '[{{SITENAME}}] New Admin Email Address' ),
     1325                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1326                'message' => __(
     1327'{{HEADER}}
     1328
    13091329You recently requested to have the administration email address on
    13101330your site changed.
    13111331
    13121332If this is correct, please click on the following link to change it:
    1313 ###ADMIN_URL###
     1333{{ADMIN_URL}}
    13141334
    13151335You can safely ignore and delete this email if you do not want to
    13161336take this action.
    13171337
    1318 This email has been sent to ###EMAIL###
     1338This email has been sent to {{EMAIL}}
    13191339
    1320 Regards,
    1321 All at ###SITENAME###
    1322 ###SITEURL###'
     1340{{FOOTER}}'
     1341                ),
     1342                'replacements' => array(
     1343                        '{{ADMIN_URL}}' => esc_url_raw( self_admin_url( 'options.php?adminhash=' . $hash ) ),
     1344                        '{{EMAIL}}' => $value,
     1345                ),
    13231346        );
    13241347
    1325         /**
    1326          * Filters the text of the email sent when a change of site admin email address is attempted.
    1327          *
    1328          * The following strings have a special meaning and will get replaced dynamically:
    1329          * ###USERNAME###  The current user's username.
    1330          * ###ADMIN_URL### The link to click on to confirm the email change.
    1331          * ###EMAIL###     The proposed new site admin email address.
    1332          * ###SITENAME###  The name of the site.
    1333          * ###SITEURL###   The URL to the site.
    1334          *
    1335          * @since MU (3.0.0)
    1336          * @since 4.9.0 This filter is no longer Multisite specific.
    1337          *
    1338          * @param string $email_text      Text in the email.
    1339          * @param array  $new_admin_email {
    1340          *     Data relating to the new site admin email address.
    1341          *
    1342          *     @type string $hash     The secure hash used in the confirmation link URL.
    1343          *     @type string $newemail The proposed new site admin email address.
    1344          * }
    1345          */
    1346         $content = apply_filters( 'new_admin_email_content', $email_text, $new_admin_email );
     1348        $wp_mailer = WP_Mailer::getInstance();
     1349        $wp_mailer->send( $wp_mail );
    13471350
    1348         $current_user = wp_get_current_user();
    1349         $content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
    1350         $content      = str_replace( '###ADMIN_URL###', esc_url( self_admin_url( 'options.php?adminhash=' . $hash ) ), $content );
    1351         $content      = str_replace( '###EMAIL###', $value, $content );
    1352         $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
    1353         $content      = str_replace( '###SITEURL###', home_url(), $content );
    1354 
    1355         wp_mail(
    1356                 $value,
    1357                 sprintf(
    1358                         /* translators: New admin email address notification email subject. %s: Site title. */
    1359                         __( '[%s] New Admin Email Address' ),
    1360                         wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
    1361                 ),
    1362                 $content
    1363         );
    1364 
    13651351        if ( $switched_locale ) {
    13661352                restore_previous_locale();
    13671353        }
  • wp-admin/includes/privacy-tools.php

     
    556556        $expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
    557557        $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
    558558
    559         $export_file_url = get_post_meta( $request_id, '_export_file_url', true );
    560         $site_name       = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    561         $site_url        = home_url();
    562 
    563559        /**
    564          * Filters the recipient of the personal data export email notification.
    565          * Should be used with great caution to avoid sending the data export link to wrong emails.
     560         * Filters removed
    566561         *
    567          * @since 5.3.0
     562         * $request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
     563         * $subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
     564         * $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
     565         * $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
    568566         *
    569          * @param string          $request_email The email address of the notification recipient.
    570          * @param WP_User_Request $request       The request that is initiating the notification.
    571          */
    572         $request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
    573 
    574         $email_data = array(
    575                 'request'           => $request,
    576                 'expiration'        => $expiration,
    577                 'expiration_date'   => $expiration_date,
    578                 'message_recipient' => $request_email,
    579                 'export_file_url'   => $export_file_url,
    580                 'sitename'          => $site_name,
    581                 'siteurl'           => $site_url,
    582         );
    583 
    584         /* translators: Personal data export notification email subject. %s: Site title. */
    585         $subject = sprintf( __( '[%s] Personal Data Export' ), $site_name );
    586 
    587         /**
    588          * Filters the subject of the email sent when an export request is completed.
     567         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    589568         *
    590          * @since 5.3.0
     569         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     570         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     571         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    591572         *
    592          * @param string $subject    The email subject.
    593          * @param string $sitename   The name of the site.
    594          * @param array  $email_data {
    595          *     Data relating to the account action email.
    596          *
    597          *     @type WP_User_Request $request           User request object.
    598          *     @type int             $expiration        The time in seconds until the export file expires.
    599          *     @type string          $expiration_date   The localized date and time when the export file expires.
    600          *     @type string          $message_recipient The address that the email will be sent to. Defaults
    601          *                                              to the value of `$request->email`, but can be changed
    602          *                                              by the `wp_privacy_personal_data_email_to` filter.
    603          *     @type string          $export_file_url   The export file URL.
    604          *     @type string          $sitename          The site name sending the mail.
    605          *     @type string          $siteurl           The site URL sending the mail.
    606          * }
    607573         */
    608         $subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
    609574
    610         /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
    611         $email_text = __(
    612                 'Howdy,
     575        $wp_mail = array(
     576                'id' => 'wp_privacy_personal_data',
     577                'group' => 'privacy',
    613578
     579                'to' => $request->email,
     580                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     581                'subject' => __( '[{{SITENAME}}] Personal Data Export' ),
     582                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     583                'message' => __(
     584'{{HEADER}}
     585
    614586Your request for an export of personal data has been completed. You may
    615587download your personal data by clicking on the link below. For privacy
    616 and security, we will automatically delete the file on ###EXPIRATION###,
     588and security, we will automatically delete the file on {{EXPIRATION}},
    617589so please download it before then.
    618590
    619 ###LINK###
     591{{EXPORTLINK}}
    620592
    621 Regards,
    622 All at ###SITENAME###
    623 ###SITEURL###'
     593{{FOOTER}}'
     594                ),
     595                'replacements' => array(
     596                        '{{EXPIRATION}}' => $expiration_date,
     597                        '{{EXPORTLINK}}' => esc_url_raw( get_post_meta( $request_id, '_export_file_url', true ) ),
     598                ),
    624599        );
    625600
    626         /**
    627          * Filters the text of the email sent with a personal data export file.
    628          *
    629          * The following strings have a special meaning and will get replaced dynamically:
    630          * ###EXPIRATION###         The date when the URL will be automatically deleted.
    631          * ###LINK###               URL of the personal data export file for the user.
    632          * ###SITENAME###           The name of the site.
    633          * ###SITEURL###            The URL to the site.
    634          *
    635          * @since 4.9.6
    636          * @since 5.3.0 Introduced the `$email_data` array.
    637          *
    638          * @param string $email_text Text in the email.
    639          * @param int    $request_id The request ID for this personal data export.
    640          * @param array  $email_data {
    641          *     Data relating to the account action email.
    642          *
    643          *     @type WP_User_Request $request           User request object.
    644          *     @type int             $expiration        The time in seconds until the export file expires.
    645          *     @type string          $expiration_date   The localized date and time when the export file expires.
    646          *     @type string          $message_recipient The address that the email will be sent to. Defaults
    647          *                                              to the value of `$request->email`, but can be changed
    648          *                                              by the `wp_privacy_personal_data_email_to` filter.
    649          *     @type string          $export_file_url   The export file URL.
    650          *     @type string          $sitename          The site name sending the mail.
    651          *     @type string          $siteurl           The site URL sending the mail.
    652          */
    653         $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
     601        $wp_mailer = WP_Mailer::getInstance();
     602        $mail_success = $wp_mailer->send( $wp_mail );
    654603
    655         $content = str_replace( '###EXPIRATION###', $expiration_date, $content );
    656         $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
    657         $content = str_replace( '###EMAIL###', $request_email, $content );
    658         $content = str_replace( '###SITENAME###', $site_name, $content );
    659         $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
    660 
    661         $headers = '';
    662 
    663         /**
    664          * Filters the headers of the email sent with a personal data export file.
    665          *
    666          * @since 5.4.0
    667          *
    668          * @param string|array $headers    The email headers.
    669          * @param string       $subject    The email subject.
    670          * @param string       $content    The email content.
    671          * @param int          $request_id The request ID.
    672          * @param array        $email_data {
    673          *     Data relating to the account action email.
    674          *
    675          *     @type WP_User_Request $request           User request object.
    676          *     @type int             $expiration        The time in seconds until the export file expires.
    677          *     @type string          $expiration_date   The localized date and time when the export file expires.
    678          *     @type string          $message_recipient The address that the email will be sent to. Defaults
    679          *                                              to the value of `$request->email`, but can be changed
    680          *                                              by the `wp_privacy_personal_data_email_to` filter.
    681          *     @type string          $export_file_url   The export file URL.
    682          *     @type string          $sitename          The site name sending the mail.
    683          *     @type string          $siteurl           The site URL sending the mail.
    684          * }
    685          */
    686         $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
    687 
    688         $mail_success = wp_mail( $request_email, $subject, $content, $headers );
    689 
    690604        if ( $switched_locale ) {
    691605                restore_previous_locale();
    692606        }
  • wp-admin/includes/schema.php

     
    11781178                $site_admins = get_site_option( 'site_admins' );
    11791179        }
    11801180
    1181         /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
     1181                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
    11821182        $welcome_email = __(
    1183                 'Howdy USERNAME,
     1183'{{HEADER}}
    11841184
    1185 Your new SITE_NAME site has been successfully set up at:
    1186 BLOG_URL
     1185Your new {{SITENAME}} site has been successfully set up at:
     1186{{SITEURL}}
    11871187
    11881188You can log in to the administrator account with the following information:
    11891189
    1190 Username: USERNAME
    1191 Password: PASSWORD
    1192 Log in here: BLOG_URLwp-login.php
     1190Username: {{USERNAME}}
     1191Password: {{PASSWORD}}
    11931192
    1194 We hope you enjoy your new site. Thanks!
     1193Log in here: {{LOGINLINK}}
    11951194
    1196 --The Team @ SITE_NAME'
     1195We hope you will enjoy your new site.
     1196
     1197{{FOOTER}}'
    11971198        );
    11981199
    11991200        $misc_exts        = array(
  • wp-admin/includes/upgrade.php

     
    603603                $name      = $user->user_login;
    604604                $login_url = wp_login_url();
    605605
    606                 $message = sprintf(
    607                         /* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL. */
    608                         __(
    609                                 'Your new WordPress site has been successfully set up at:
     606                $wp_mail = array(
     607                        'id' => 'install',
     608                        'group' => 'admin',
    610609
    611 %1$s
     610                        'to' => $user->user_email,
     611                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     612                        'subject' => __( '[{{SITENAME}}] New WordPress Site' ),
     613                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     614                        'message' => __(
     615'Your new WordPress site has been successfully set up at:
    612616
     617{{SITEURL}}
     618
    613619You can log in to the administrator account with the following information:
    614620
    615 Username: %2$s
    616 Password: %3$s
    617 Log in here: %4$s
     621Username: {{USERNAME}}
     622Password: {{PASSWORD}}
    618623
     624Log in here: {{LOGINLINK}}
     625
    619626We hope you enjoy your new site. Thanks!
    620627
    621628--The WordPress Team
    622 https://wordpress.org/
    623 '
     629https://wordpress.org/' ),
     630                        'replacements' => array(
     631                                '{{SITEURL}}'   => esc_url_raw( $blog_url ),
     632                                '{{SITENAME}}'  => $blog_title,
     633                                '{{USERNAME}}'  => $user->user_login,
     634                                '{{PASSWORD}}'  => $password,
     635                                '{{LOGINLINK}}' => esc_url_raw( wp_login_url() ),
    624636                        ),
    625                         $blog_url,
    626                         $name,
    627                         $password,
    628                         $login_url
    629637                );
    630638
    631                 wp_mail( $email, __( 'New WordPress Site' ), $message );
     639                $wp_mailer = WP_Mailer::getInstance();
     640                $wp_mailer->send( $wp_mail );
    632641        }
    633642endif;
    634643
  • wp-admin/ms-delete-site.php

     
    5252
    5353        $switched_locale = switch_to_locale( get_locale() );
    5454
    55         /* translators: Do not translate USERNAME, URL_DELETE, SITE_NAME: those are placeholders. */
    56         $content = __(
    57                 "Howdy ###USERNAME###,
     55        /**
     56         * Filter removed
     57         *
     58         * $content = apply_filters( 'delete_site_email_content', $content );
     59         *
     60         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     61         *
     62         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     63         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     64         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     65         *
     66         */
    5867
    59 You recently clicked the 'Delete Site' link on your site and filled in a
     68        $wp_mail = array(
     69                'id' => 'delete_site_email',
     70                'group' => 'ms',
     71
     72                'to' => get_option( 'admin_email' ),
     73                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     74                'subject' => __( '[{{SITENAME}}] Delete My Site' ),
     75                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     76                'message' => __(
     77'{{HEADER}}
     78
     79As {{USERNAME}}, you recently clicked the \'Delete Site\' link on your site and filled in a
    6080form on that page.
    6181
    6282If you really want to delete your site, click the link below. You will not
    6383be asked to confirm again so only click this link if you are absolutely certain:
    64 ###URL_DELETE###
     84{{URL_DELETE}}
    6585
    6686If you delete your site, please consider opening a new site here
    6787some time in the future! (But remember your current site and username
    6888are gone forever.)
    6989
    70 Thanks for using the site,
    71 Webmaster
    72 ###SITE_NAME###"
     90{{FOOTER}}'
     91                ),
     92                'replacements' => array(
     93                        '{{URL_DELETE}}' => esc_url_raw( admin_url( 'ms-delete-site.php?h=' . $hash ) )
     94                ),
    7395        );
    74         /**
    75          * Filters the email content sent when a site in a Multisite network is deleted.
    76          *
    77          * @since 3.0.0
    78          *
    79          * @param string $content The email content that will be sent to the user who deleted a site in a Multisite network.
    80          */
    81         $content = apply_filters( 'delete_site_email_content', $content );
    8296
    83         $content = str_replace( '###USERNAME###', $user->user_login, $content );
    84         $content = str_replace( '###URL_DELETE###', $url_delete, $content );
    85         $content = str_replace( '###SITE_NAME###', get_network()->site_name, $content );
     97        $wp_mailer = WP_Mailer::getInstance();
     98        $wp_mailer->send( $wp_mail );
    8699
    87         wp_mail(
    88                 get_option( 'admin_email' ),
    89                 sprintf(
    90                         /* translators: %s: Site title. */
    91                         __( '[%s] Delete My Site' ),
    92                         wp_specialchars_decode( get_option( 'blogname' ) )
    93                 ),
    94                 $content
    95         );
    96 
    97100        if ( $switched_locale ) {
    98101                restore_previous_locale();
    99102        }
  • wp-admin/network/site-new.php

     
    144144                        update_user_option( $user_id, 'primary_blog', $id, true );
    145145                }
    146146
    147                 wp_mail(
    148                         get_site_option( 'admin_email' ),
    149                         sprintf(
    150                                 /* translators: New site notification email subject. %s: Network title. */
    151                                 __( '[%s] New Site Created' ),
    152                                 get_network()->site_name
    153                         ),
    154                         sprintf(
    155                                 /* translators: New site notification email. 1: User login, 2: Site URL, 3: Site title. */
    156                                 __(
    157                                         'New site created by %1$s
     147                $admin_email = get_site_option( 'admin_email' );
    158148
    159 Address: %2$s
    160 Name: %3$s'
    161                                 ),
    162                                 $current_user->user_login,
    163                                 get_site_url( $id ),
    164                                 wp_unslash( $title )
     149                /**
     150                 *
     151                 * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     152                 *
     153                 *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     154                 *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     155                 *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     156                 *
     157                 */
     158
     159
     160                $wp_mail = array(
     161                        'id' => 'site_new',
     162                        'group' => 'network',
     163
     164                        'to' => get_site_option( 'admin_email' ),
     165                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     166                        'subject' => __( '[{{SITENAME}}] New Site Created' ),
     167                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     168                        'message' => __(
     169'{{HEADER}}
     170
     171New site created by {{USERNAME}}
     172
     173Address: {{SITEURL}}
     174Name: {{BLOGNAME}}
     175
     176{{FOOTER}}'
    165177                        ),
    166                         sprintf(
    167                                 'From: "%1$s" <%2$s>',
    168                                 _x( 'Site Admin', 'email "From" field' ),
    169                                 get_site_option( 'admin_email' )
    170                         )
     178                        'headers' => array(
     179                                'From' => "{$admin_email} <{$admin_email}>",
     180                        ),
     181                        'replacements' => array(
     182                                '{{SITENAME}}' => get_network()->site_name,
     183                                '{{SITEURL}}'  => esc_url_raw( get_site_url( $id ) ),
     184                                '{{USERNAME}}' => $current_user->user_login,
     185                                '{{BLOGNAME}}' => wp_unslash( $title ),
     186                        ),
    171187                );
     188
     189                $wp_mailer = WP_Mailer::getInstance();
     190                $wp_mailer->send( $wp_mail );
     191
    172192                wpmu_welcome_notification( $id, $user_id, $password, $title, array( 'public' => 1 ) );
    173193                wp_redirect(
    174194                        add_query_arg(
  • wp-admin/user-new.php

     
    112112
    113113                        $switched_locale = switch_to_locale( get_user_locale( $user_details ) );
    114114
    115                         /* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
    116                         $message = __(
    117                                 'Hi,
     115                        /**
     116                         * No filter removed
     117                         *
     118                         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     119                         *
     120                         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     121                         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );       
     122                         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     123                         *
     124                         */
    118125
    119 You\'ve been invited to join \'%1$s\' at
    120 %2$s with the role of %3$s.
     126                        $wp_mail = array(
     127                                'id' => 'invite',
     128                                'group' => 'blog',
    121129
     130                                'to' => $new_user_email,
     131                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     132                                'subject' => __( '[{{SITENAME}}] Joining Confirmation' ),
     133                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     134                                'message' => __(
     135'{{HEADER}}
     136
     137You have been invited to join "{{SITENAME}}" at
     138{{SITEURL}} with the role of {{ROLE}}.
     139
    122140Please click the following link to confirm the invite:
    123 %4$s'
    124                         );
     141{{INVITE_URL}}
    125142
    126                         wp_mail(
    127                                 $new_user_email,
    128                                 sprintf(
    129                                         /* translators: Joining confirmation notification email subject. %s: Site title. */
    130                                         __( '[%s] Joining Confirmation' ),
    131                                         wp_specialchars_decode( get_option( 'blogname' ) )
     143{{FOOTER}}'
    132144                                ),
    133                                 sprintf(
    134                                         $message,
    135                                         get_option( 'blogname' ),
    136                                         home_url(),
    137                                         wp_specialchars_decode( translate_user_role( $role['name'] ) ),
    138                                         home_url( "/newbloguser/$newuser_key/" )
    139                                 )
     145                                'replacements' => array(
     146                                        '{{ROLE}}'       => translate_user_role( $role['name'] ),
     147                                        '{{INVITE_URL}}' => esc_url_raw( home_url( "/newbloguser/$newuser_key/" ) ),
     148                                ),
    140149                        );
    141150
     151                        $wp_mailer = WP_Mailer::getInstance();
     152                        $wp_mailer->send( $wp_mail );
     153
     154
    142155                        if ( $switched_locale ) {
    143156                                restore_previous_locale();
    144157                        }
  • wp-includes/class-wp-mailer.php

     
     1<?php
     2/**
     3 * API for easily sending customisable mails.
     4 *
     5 * @package WordPress
     6 * @subpackage Mail
     7 * @since 5.5.0
     8 */
     9
     10class WP_Mailer{
     11
     12        /**
     13         * Unique class instance
     14         *
     15         * @static object
     16         */
     17        private static $_instance = null;
     18
     19        /**
     20         * Stores generated mail ids for uniqueness
     21         *
     22         * @static array
     23         */
     24        private static $_ids = array();
     25
     26        /**
     27         * The occurence of debug_backtrace to identify the caller
     28         *
     29         * @var array
     30         */
     31        private $call = array();
     32
     33        /**
     34         * Constructor
     35         *
     36         * Constructor is private, use GLOBALS variable $wp_mailer or getInstance() static function instead
     37         */
     38        private function __construct() { 
     39        }
     40 
     41         /**
     42          * Returns class instance
     43          *
     44          * @return object Class instance.
     45          */
     46        public static function getInstance() {
     47 
     48                if ( is_null( self::$_instance ) ) {
     49                        self::$_instance = new self();
     50                }
     51
     52                return self::$_instance;
     53        }
     54
     55        /**
     56         * Sending using wp_mail.
     57         *
     58         * @param array $mail The mail parameters, an array with structured information to send mail
     59         *      to      : (string|array) the email recipient(s)
     60         *      subject : (string) mail subject
     61         *      message : (string) message content before replacements
     62         *      headers : (string|array) if an array, each item is a pair of ( Header => Value, )
     63         *                               example 1 : array( 'From' => 'me@my.awesome.blog', )
     64         *                               example 2 : array( 'X-Repeatable' => array( 'value1', 'value2', )
     65         *      attachments : (string|array)
     66         *
     67         *      replacements : (array) each item is a pair of ( Text_to_replace => Text_replaced )
     68         *                               example : array( '{{MYEMAIL}}' => 'me@my.awesome.blog', )
     69         *      id : (string) used to individualize filter
     70         *
     71         * @return bool Whether the mail was sent successfully.
     72         */
     73        public function send( $mail ) {
     74
     75                $this->get_called();
     76
     77                $current_user = wp_get_current_user();
     78
     79                $defaults = array(
     80                        'id' => $this->get_mail_id(),
     81                        'group' => 'wordpress',
     82
     83                        'subject' => '',
     84                        'message' => '',
     85                        'headers' => array(),
     86                        'attachments' => array(),
     87
     88                        /* make sure reserved words {{HEADER}} and {{FOOTER}} are first. */
     89                        'replacements' => array(
     90                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     91                                '{{HEADER}}'   => __( '{{SITENAME}}
     92{{SITEURL}}
     93
     94Hello,' ),
     95                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     96                                '{{FOOTER}}'   => __( 'With gratitude' ),
     97                                '{{SITENAME}}' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
     98                                '{{SITEURL}}'  => esc_url_raw( home_url() ),
     99                                '{{USERNAME}}' => $current_user->user_login,
     100                        ),
     101                );
     102
     103                /**
     104                 * Filters the default message components.
     105                 *
     106                 * @since 5.5
     107                 *
     108                 * @param array  $defaults   Default values of api.
     109                 * @param array  $mail       Current values of api.
     110                 * @param array  $call       Debug_backtrace occurence of api caller.
     111                 */
     112                $defaults = apply_filters( 'wp_mailer_defaults', $defaults, $mail, $this->call );
     113
     114                $mail = array_replace_recursive( $defaults, $mail );
     115
     116
     117                /**
     118                 * Filters the message components for a specific mail.
     119                 *
     120                 * @since 5.5
     121                 *
     122                 * @param array  $mail       Current values of api.
     123                 * @param array  $call       Debug_backtrace occurence of api caller.
     124                 */
     125                $mail = apply_filters( "wp_mailer_{$mail['id']}", $mail, $this->call );
     126               
     127                /**
     128                 * Filters the message components for a group of mails ( network, ms, admin, blog, privacy, ...)
     129                 *
     130                 * @since 5.5
     131                 *
     132                 * @param array  $mail       Current values of api.
     133                 * @param array  $call       Debug_backtrace occurence of api caller.
     134                 */
     135                $mail = apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $this->call );
     136
     137                /**
     138                 * Filters the message components.
     139                 *
     140                 * @since 5.5
     141                 *
     142                 * @param array  $mail       Current values of api.
     143                 * @param array  $call       Debug_backtrace occurence of api caller.
     144                 */
     145                $mail = apply_filters( "wp_mailer_mail", $mail, $this->call );
     146
     147                $search = array_keys( $mail['replacements'] );
     148                $mail['subject'] = str_replace( $search, $mail['replacements'], $mail['subject'] );
     149                $mail['subject'] = wp_specialchars_decode( $mail['subject'], ENT_QUOTES );
     150                $mail['message'] = str_replace( $search, $mail['replacements'], $mail['message'] );
     151                $mail['message'] = wp_specialchars_decode( $mail['message'], ENT_QUOTES );
     152
     153                /* to can be an array */               
     154                if ( !isset( $mail['to'] ) ) return false;
     155                if ( !is_array( $mail['to'] ) ) $mail['to'] = array( $mail['to'] );
     156                else $mail['to'] = array_unique( $mail['to'] );
     157               
     158                /* headers argument is mixed (string|array) in wp_mail */
     159                if ( is_array( $mail['headers'] ) ) {
     160                        $headers = array();
     161                        foreach( $mail['headers'] as $key => $value ) {
     162                                if ( is_array( $value ) ) {         /* repeatable header */
     163                                        foreach( $value as $v ) {
     164                                                $headers[] = trim( $key ) . ': ' . trim( $v ) . "\n";
     165                                        }
     166                                }
     167                                else
     168                                {
     169                                        $headers[] = trim( $key ) . ': ' . trim( $value ) . "\n";
     170                                }
     171                        }
     172                }
     173                else
     174                {
     175                        $headers = $mail['headers'];
     176                }
     177               
     178                $return = true;
     179
     180                foreach( $mail['to'] as $to )
     181                {
     182                        if ( ! $return ) break;
     183                        $return = wp_mail(
     184                                        $to,
     185                                        $mail['subject'],
     186                                        $mail['message'],
     187                                        $headers,
     188                                        $mail['attachments']
     189                        );
     190                }
     191
     192                return $return;
     193        }
     194
     195        /**
     196         * Generates a mail id based on caller and occurence
     197         *
     198         */
     199        private function get_mail_id() {
     200
     201                if ( empty( $this->call ) ) return 'unknown';
     202
     203                $ids = array();
     204                if ( isset( $this->call['class'] ) )    $ids[] = $this->call['class'];
     205                if ( isset( $this->call['function'] ) ) $ids[] = $this->call['function'];
     206                if ( empty( $ids ) && isset( $this->call['file'] ) ) $ids[] = substr( basename( $this->call['file'] ), 0, -4 );
     207                $id = implode ( '_', $ids );
     208                if ( isset( self::$_ids[$id] ) )  $ids[] = ++self::$_ids[$id];
     209                else self::$_ids[$id] = 0;                             
     210
     211                return implode ( '_', $ids );
     212        }
     213
     214        /**
     215         * For filters and eventually mail id (caller and arguments)
     216         *
     217         */
     218        private function get_called() {
     219                $calls = debug_backtrace();
     220                $call = array();
     221                for( $i = 2; $i >= 0; $i-- ) {
     222                        if ( isset( $calls[$i] ) ) {
     223                                $call = $calls[$i];
     224                                break;
     225                        }
     226                }
     227                $this->call = $call;
     228        }
     229}
     230 No newline at end of file
  • wp-includes/functions.php

     
    70097009                return;
    70107010        }
    70117011
    7012         /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
    7013         $email_change_text = __(
    7014                 'Hi,
    7015 
    7016 This notice confirms that the admin email address was changed on ###SITENAME###.
    7017 
    7018 The new admin email address is ###NEW_EMAIL###.
    7019 
    7020 This email has been sent to ###OLD_EMAIL###
    7021 
    7022 Regards,
    7023 All at ###SITENAME###
    7024 ###SITEURL###'
    7025         );
    7026 
    7027         $email_change_email = array(
    7028                 'to'      => $old_email,
    7029                 /* translators: Site admin email change notification email subject. %s: Site title. */
    7030                 'subject' => __( '[%s] Admin Email Changed' ),
    7031                 'message' => $email_change_text,
    7032                 'headers' => '',
    7033         );
    7034 
    7035         // Get site name.
    7036         $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    7037 
    70387012        /**
    7039          * Filters the contents of the email notification sent when the site admin email address is changed.
     7013         * Filter removed
    70407014         *
    7041          * @since 4.9.0
     7015         * $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email );
    70427016         *
    7043          * @param array $email_change_email {
    7044          *            Used to build wp_mail().
     7017         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    70457018         *
    7046          *            @type string $to      The intended recipient.
    7047          *            @type string $subject The subject of the email.
    7048          *            @type string $message The content of the email.
    7049          *                The following strings have a special meaning and will get replaced dynamically:
    7050          *                - ###OLD_EMAIL### The old site admin email address.
    7051          *                - ###NEW_EMAIL### The new site admin email address.
    7052          *                - ###SITENAME###  The name of the site.
    7053          *                - ###SITEURL###   The URL to the site.
    7054          *            @type string $headers Headers.
    7055          *        }
    7056          * @param string $old_email The old site admin email address.
    7057          * @param string $new_email The new site admin email address.
     7019         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     7020         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     7021         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     7022         *
    70587023         */
    7059         $email_change_email = apply_filters( 'site_admin_email_change_email', $email_change_email, $old_email, $new_email );
    70607024
    7061         $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );
    7062         $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );
    7063         $email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] );
    7064         $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
     7025        $wp_mail = array(
     7026                'id' => 'site_admin_email_change',
     7027                'group' => 'admin',
    70657028
    7066         wp_mail(
    7067                 $email_change_email['to'],
    7068                 sprintf(
    7069                         $email_change_email['subject'],
    7070                         $site_name
     7029                'to' => $old_email,
     7030                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     7031                'subject' => __( '[{{SITENAME}}] Admin Email Changed' ),
     7032                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     7033                'message' => __(
     7034'{{HEADER}}
     7035
     7036This notice confirms that the admin email address was changed on {{SITENAME}}.
     7037
     7038The new admin email address is {{NEW_EMAIL}}.
     7039
     7040This email has been sent to {{OLD_EMAIL}}.
     7041
     7042{{FOOTER}}'
    70717043                ),
    7072                 $email_change_email['message'],
    7073                 $email_change_email['headers']
     7044                'replacements' => array(
     7045                        '{{OLD_EMAIL}}' => $old_email,
     7046                        '{{NEW_EMAIL}}' => $new_email,
     7047
     7048                ),
    70747049        );
     7050
     7051        $wp_mailer = WP_Mailer::getInstance();
     7052        $wp_mailer->send( $wp_mail );
    70757053}
    70767054
    70777055/**
  • wp-includes/ms-functions.php

     
    903903 * Filter {@see 'wpmu_signup_blog_notification'} to bypass this function or
    904904 * replace it with your own notification behavior.
    905905 *
    906  * Filter {@see 'wpmu_signup_blog_notification_email'} and
    907  * {@see 'wpmu_signup_blog_notification_subject'} to change the content
    908  * and subject line of the email sent to newly registered users.
    909  *
    910906 * @since MU (3.0.0)
    911907 *
    912908 * @param string $domain     The new blog domain.
     
    949945                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    950946        }
    951947        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    952         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
    953948
    954949        $user            = get_user_by( 'login', $user_login );
     950
     951        $new_siteurl = is_ssl() ? 'https://' : 'http://';
     952        $new_siteurl .= $domain . $path;
     953
    955954        $switched_locale = switch_to_locale( get_user_locale( $user ) );
    956955
    957         $message = sprintf(
    958                 /**
    959                  * Filters the message content of the new blog notification email.
    960                  *
    961                  * Content should be formatted for transmission via wp_mail().
    962                  *
    963                  * @since MU (3.0.0)
    964                  *
    965                  * @param string $content    Content of the notification email.
    966                  * @param string $domain     Site domain.
    967                  * @param string $path       Site path.
    968                  * @param string $title      Site title.
    969                  * @param string $user_login User login name.
    970                  * @param string $user_email User email address.
    971                  * @param string $key        Activation key created in wpmu_signup_blog().
    972                  * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
    973                  */
    974                 apply_filters(
    975                         'wpmu_signup_blog_notification_email',
    976                         /* translators: New site notification email. 1: Activation URL, 2: New site URL. */
    977                         __( "To activate your blog, please click the following link:\n\n%1\$s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%2\$s" ),
    978                         $domain,
    979                         $path,
    980                         $title,
    981                         $user_login,
    982                         $user_email,
    983                         $key,
    984                         $meta
    985                 ),
    986                 $activate_url,
    987                 esc_url( "http://{$domain}{$path}" ),
    988                 $key
    989         );
    990956
    991         $subject = sprintf(
    992                 /**
    993                  * Filters the subject of the new blog notification email.
    994                  *
    995                  * @since MU (3.0.0)
    996                  *
    997                  * @param string $subject    Subject of the notification email.
    998                  * @param string $domain     Site domain.
    999                  * @param string $path       Site path.
    1000                  * @param string $title      Site title.
    1001                  * @param string $user_login User login name.
    1002                  * @param string $user_email User email address.
    1003                  * @param string $key        Activation key created in wpmu_signup_blog().
    1004                  * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
    1005                  */
    1006                 apply_filters(
    1007                         'wpmu_signup_blog_notification_subject',
    1008                         /* translators: New site notification email subject. 1: Network title, 2: New site URL. */
    1009                         _x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
    1010                         $domain,
    1011                         $path,
    1012                         $title,
    1013                         $user_login,
    1014                         $user_email,
    1015                         $key,
    1016                         $meta
     957        /**
     958         * Filters removed
     959         *
     960         *      $message = sprintf(
     961         *              apply_filters(
     962         *                      'wpmu_signup_blog_notification_email',
     963         *                      __( "To activate your blog, please click the following link:\n\n%1\$s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%2\$s" ),
     964         *                      $domain,
     965         *                      $path,
     966         *                      $title,
     967         *                      $user_login,
     968         *                      $user_email,
     969         *                      $key,
     970         *                      $meta
     971         *              ),
     972         *              $activate_url,
     973         *              esc_url( "http://{$domain}{$path}" ),
     974         *              $key
     975         *      );
     976         *
     977         *      $subject = sprintf(
     978         *              apply_filters(
     979         *                      'wpmu_signup_blog_notification_subject',
     980         *                      _x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
     981         *                      $domain,
     982         *                      $path,
     983         *                      $title,
     984         *                      $user_login,
     985         *                      $user_email,
     986         *                      $key,
     987         *                      $meta
     988         *              ),
     989         *              $from_name,
     990         *              esc_url( 'http://' . $domain . $path )
     991         *      );
     992         *
     993         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     994         *
     995         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     996         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     997         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     998         *
     999         */
     1000
     1001        $wp_mail = array(
     1002                'id' => 'wpmu_signup_blog_notification',
     1003                'group' => 'ms',
     1004
     1005                'to' => $user_email,
     1006                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1007                'subject' => __( '[{{SITENAME}}] Activate {{NEW_SITEURL}}' ),
     1008                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1009                'message' => __(
     1010'{{HEADER}}
     1011
     1012To activate your blog, please click the following link: {{ACTIVATE_URL}}
     1013
     1014After you activate, you will receive *another email* with your login
     1015
     1016and you will be able to visit your new site here: {{NEW_SITEURL}}
     1017
     1018{{FOOTER}}'
    10171019                ),
    1018                 $from_name,
    1019                 esc_url( 'http://' . $domain . $path )
     1020                'headers' => array(
     1021                        'From' => "{$from_name} <{$admin_email}>",
     1022                        'Content-Type' => 'text/plain; charset="' . get_option( 'blog_charset' ) . '"',
     1023                ),
     1024                'replacements' => array(
     1025                        '{{SITENAME}}'     => $from_name,
     1026                        '{{USERNAME}}'     => $user_login,
     1027                        '{{ACTIVATE_URL}}' => esc_url_raw( $activate_url ),
     1028                        '{{NEW_SITEURL}}'  => esc_url_raw( $new_siteurl ),
     1029                ),
    10201030        );
    10211031
    1022         wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
     1032        $wp_mailer = WP_Mailer::getInstance();
     1033        $wp_mailer->send( $wp_mail );
    10231034
    10241035        if ( $switched_locale ) {
    10251036                restore_previous_locale();
     
    10381049 * Filter {@see 'wpmu_signup_user_notification'} to bypass this function or
    10391050 * replace it with your own notification behavior.
    10401051 *
    1041  * Filter {@see 'wpmu_signup_user_notification_email'} and
    1042  * {@see 'wpmu_signup_user_notification_subject'} to change the content
    1043  * and subject line of the email sent to newly registered users.
    1044  *
    10451052 * @since MU (3.0.0)
    10461053 *
    10471054 * @param string $user_login The user's login name.
     
    10661073        }
    10671074
    10681075        $user            = get_user_by( 'login', $user_login );
    1069         $switched_locale = switch_to_locale( get_user_locale( $user ) );
    10701076
    10711077        // Send email with activation link.
    10721078        $admin_email = get_site_option( 'admin_email' );
     
    10741080                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    10751081        }
    10761082        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    1077         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
    1078         $message         = sprintf(
    1079                 /**
    1080                  * Filters the content of the notification email for new user sign-up.
    1081                  *
    1082                  * Content should be formatted for transmission via wp_mail().
    1083                  *
    1084                  * @since MU (3.0.0)
    1085                  *
    1086                  * @param string $content    Content of the notification email.
    1087                  * @param string $user_login User login name.
    1088                  * @param string $user_email User email address.
    1089                  * @param string $key        Activation key created in wpmu_signup_user().
    1090                  * @param array  $meta       Signup meta data. Default empty array.
    1091                  */
    1092                 apply_filters(
    1093                         'wpmu_signup_user_notification_email',
    1094                         /* translators: New user notification email. %s: Activation URL. */
    1095                         __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
    1096                         $user_login,
    1097                         $user_email,
    1098                         $key,
    1099                         $meta
    1100                 ),
    1101                 site_url( "wp-activate.php?key=$key" )
    1102         );
    11031083
    1104         $subject = sprintf(
    1105                 /**
    1106                  * Filters the subject of the notification email of new user signup.
    1107                  *
    1108                  * @since MU (3.0.0)
    1109                  *
    1110                  * @param string $subject    Subject of the notification email.
    1111                  * @param string $user_login User login name.
    1112                  * @param string $user_email User email address.
    1113                  * @param string $key        Activation key created in wpmu_signup_user().
    1114                  * @param array  $meta       Signup meta data. Default empty array.
    1115                  */
    1116                 apply_filters(
    1117                         'wpmu_signup_user_notification_subject',
    1118                         /* translators: New user notification email subject. 1: Network title, 2: New user login. */
    1119                         _x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
    1120                         $user_login,
    1121                         $user_email,
    1122                         $key,
    1123                         $meta
     1084        $switched_locale = switch_to_locale( get_user_locale( $user ) );
     1085
     1086        /**
     1087         * Filters removed
     1088         *
     1089         * $message         = sprintf(
     1090         *              apply_filters(
     1091         *                      'wpmu_signup_user_notification_email',
     1092         *                      __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
     1093         *                      $user_login,
     1094         *                      $user_email,
     1095         *                      $key,
     1096         *                      $meta
     1097         *              ),
     1098         *              site_url( "wp-activate.php?key=$key" )
     1099         * );
     1100         *
     1101         * $subject = sprintf(
     1102         *              apply_filters(
     1103         *                      'wpmu_signup_user_notification_subject',
     1104         *                      _x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
     1105         *                      $user_login,
     1106         *                      $user_email,
     1107         *                      $key,
     1108         *                      $meta
     1109         *              ),
     1110         *              $from_name,
     1111         *              $user_login
     1112         * );
     1113         *
     1114         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     1115         *
     1116         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1117         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1118         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1119         *
     1120         */
     1121
     1122        $wp_mail = array(
     1123                'id' => 'wpmu_signup_user_notification',
     1124                'group' => 'ms',
     1125
     1126                'to' => $user_email,
     1127                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1128                'subject' => __( '[{{SITENAME}}] Activate {{USERNAME}}' ),
     1129                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1130                'message' => __(
     1131'{{HEADER}}
     1132
     1133To activate your user, please click the following link: {{ACTIVATE_URL}}
     1134
     1135After you activate, you will receive *another email* with your login.
     1136
     1137{{FOOTER}}'
    11241138                ),
    1125                 $from_name,
    1126                 $user_login
     1139                'headers' => array(
     1140                        'From' => "{$from_name} <{$admin_email}>",
     1141                        'Content-Type' => 'text/plain; charset="' . get_option( 'blog_charset' ) . '"',
     1142                ),
     1143                'replacements' => array(
     1144                        '{{SITENAME}}'     => $from_name,
     1145                        '{{USERNAME}}'     => $user_login,
     1146                        '{{ACTIVATE_URL}}' => esc_url_raw( site_url( "wp-activate.php?key={$key}" ) ),
     1147                ),
    11271148        );
    11281149
    1129         wp_mail( $user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
     1150        $wp_mailer = WP_Mailer::getInstance();
     1151        $wp_mailer->send( $wp_mail );
    11301152
    11311153        if ( $switched_locale ) {
    11321154                restore_previous_locale();
     
    13831405/**
    13841406 * Notifies the network admin that a new site has been activated.
    13851407 *
    1386  * Filter {@see 'newblog_notify_siteadmin'} to change the content of
    1387  * the notification email.
    1388  *
    13891408 * @since MU (3.0.0)
    1390  * @since 5.1.0 $blog_id now supports input from the {@see 'wp_initialize_site'} action.
    13911409 *
    13921410 * @param WP_Site|int $blog_id    The new site's object or ID.
    13931411 * @param string      $deprecated Not used.
     
    14071425                return false;
    14081426        }
    14091427
    1410         $options_site_url = esc_url( network_admin_url( 'settings.php' ) );
    1411 
    14121428        switch_to_blog( $blog_id );
    14131429        $blogname = get_option( 'blogname' );
    14141430        $siteurl  = site_url();
    14151431        restore_current_blog();
    14161432
    1417         $msg = sprintf(
    1418                 /* translators: New site notification email. 1: Site URL, 2: User IP address, 3: URL to Network Settings screen. */
    1419                 __(
    1420                         'New Site: %1$s
    1421 URL: %2$s
    1422 Remote IP address: %3$s
    1423 
    1424 Disable these notifications: %4$s'
    1425                 ),
    1426                 $blogname,
    1427                 $siteurl,
    1428                 wp_unslash( $_SERVER['REMOTE_ADDR'] ),
    1429                 $options_site_url
    1430         );
    14311433        /**
    1432          * Filters the message body of the new site activation email sent
    1433          * to the network administrator.
     1434         * Filter removed
    14341435         *
    1435          * @since MU (3.0.0)
    1436          * @since 5.4.0 The `$blog_id` parameter was added.
     1436         * $msg = apply_filters( 'newblog_notify_siteadmin', $msg, $blog_id );
    14371437         *
    1438          * @param string $msg     Email body.
    1439          * @param int    $blog_id The new site's ID.
     1438         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     1439         *
     1440         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1441         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1442         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1443         *
    14401444         */
    1441         $msg = apply_filters( 'newblog_notify_siteadmin', $msg, $blog_id );
    14421445
    1443         /* translators: New site notification email subject. %s: New site URL. */
    1444         wp_mail( $email, sprintf( __( 'New Site Registration: %s' ), $siteurl ), $msg );
     1446        $wp_mail = array(
     1447                'id' => 'newblog_notify_siteadmin',
     1448                'group' => 'network',
    14451449
     1450                'to' => $email,
     1451                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1452                'subject' => __( 'New Site Registration: {{SITEURL}}' ),
     1453                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1454                'message' => __(
     1455'{{HEADER}}
     1456
     1457New Site: {{SITENAME}}
     1458URL : {{SITEURL}}
     1459Remote IP address : {{REMOTEADDR}}
     1460
     1461Disable these notifications: {{ADMIN_URL}}
     1462
     1463{{FOOTER}}'
     1464                ),
     1465                'replacements' => array(
     1466                        '{{SITEURL}}'     => esc_url_raw( $siteurl ),
     1467                        '{{REMOTEADDR}}'  => wp_unslash( $_SERVER['REMOTE_ADDR'] ),
     1468                        '{{ADMIN_URL}}'   => esc_url_raw( network_admin_url( 'settings.php' ) ),
     1469                ),
     1470        );
     1471
     1472        $wp_mailer = WP_Mailer::getInstance();
     1473        $wp_mailer->send( $wp_mail );
     1474
    14461475        return true;
    14471476}
    14481477
     
    14491478/**
    14501479 * Notifies the network admin that a new user has been activated.
    14511480 *
    1452  * Filter {@see 'newuser_notify_siteadmin'} to change the content of
    1453  * the notification email.
    1454  *
    14551481 * @since MU (3.0.0)
    14561482 *
    14571483 * @param int $user_id The new user's ID.
     
    14701496
    14711497        $user = get_userdata( $user_id );
    14721498
    1473         $options_site_url = esc_url( network_admin_url( 'settings.php' ) );
     1499        /**
     1500         * Filter removed
     1501         *
     1502         * $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
     1503         *
     1504         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     1505         *
     1506         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1507         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1508         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1509         *
     1510         */
    14741511
    1475         $msg = sprintf(
    1476                 /* translators: New user notification email. 1: User login, 2: User IP address, 3: URL to Network Settings screen. */
    1477                 __(
    1478                         'New User: %1$s
    1479 Remote IP address: %2$s
     1512        $wp_mail = array(
     1513                'id' => 'newuser_notify_siteadmin',
     1514                'group' => 'network',
    14801515
    1481 Disable these notifications: %3$s'
     1516                'to' => $email,
     1517                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1518                'subject' => __( 'New User Registration: {{USERNAME}}' ),
     1519                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1520                'message' => __(
     1521'{{HEADER}}
     1522
     1523New User: {{USERNAME}}
     1524
     1525Remote IP address : {{REMOTEADDR}}
     1526
     1527Disable these notifications: {{ADMIN_URL}}
     1528
     1529{{FOOTER}}'
    14821530                ),
    1483                 $user->user_login,
    1484                 wp_unslash( $_SERVER['REMOTE_ADDR'] ),
    1485                 $options_site_url
     1531                'replacements' => array(
     1532                        '{{USERNAME}}'    => $user->user_login,
     1533                        '{{REMOTEADDR}}'  => wp_unslash( $_SERVER['REMOTE_ADDR'] ),
     1534                        '{{ADMIN_URL}}'   => esc_url_raw( network_admin_url( 'settings.php' ) ),
     1535                ),
    14861536        );
    14871537
    1488         /**
    1489          * Filters the message body of the new user activation email sent
    1490          * to the network administrator.
    1491          *
    1492          * @since MU (3.0.0)
    1493          *
    1494          * @param string  $msg  Email body.
    1495          * @param WP_User $user WP_User instance of the new user.
    1496          */
    1497         $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
     1538        $wp_mailer = WP_Mailer::getInstance();
     1539        $wp_mailer->send( $wp_mail );
    14981540
    1499         /* translators: New user notification email subject. %s: User login. */
    1500         wp_mail( $email, sprintf( __( 'New User Registration: %s' ), $user->user_login ), $msg );
    1501 
    15021541        return true;
    15031542}
    15041543
     
    15521591 *
    15531592 * Filter {@see 'wpmu_welcome_notification'} to disable or bypass.
    15541593 *
    1555  * Filter {@see 'update_welcome_email'} and {@see 'update_welcome_subject'} to
    1556  * modify the content and subject line of the notification email.
    1557  *
    15581594 * @since MU (3.0.0)
    15591595 *
    15601596 * @param int    $blog_id  Blog ID.
     
    15651601 * @return bool
    15661602 */
    15671603function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
    1568         $current_network = get_network();
    1569 
    15701604        /**
    15711605         * Filters whether to bypass the welcome email after site activation.
    15721606         *
     
    15841618                return false;
    15851619        }
    15861620
     1621        $current_network = get_network();
     1622        if ( empty( $current_network->site_name ) ) {
     1623                $current_network->site_name = 'WordPress';
     1624        }
     1625
    15871626        $user = get_userdata( $user_id );
    15881627
     1628        $admin_email   = get_site_option( 'admin_email' );
     1629
     1630        if ( '' == $admin_email ) {
     1631                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1632        }
     1633        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
     1634
     1635        $url       = get_blogaddress_by_id( $blog_id );
     1636        $login_url = $url . 'wp-login.php';
     1637
     1638        // Back-compat for pre-5.5.
     1639        $welcome_backward_compat = array( 'SITE_NAME' => '{{SITENAME}}', 'BLOG_URL' => '{{SITEURL}}', 'USERNAME' => '{{USERNAME}}', 'PASSWORD' => '{{PASSWORD}}', 'BLOG_URLwp-login.php' => '{{LOGINLINK}}', '{{{{' => '{{', '}}}}' => '}}', );
     1640        $welcome_search = array_keys( $welcome_backward_compat );
     1641        $welcome_email = get_site_option( 'welcome_email' );
     1642        $welcome_email = str_replace( $welcome_search, $welcome_backward_compat, $welcome_email );
     1643
    15891644        $switched_locale = switch_to_locale( get_user_locale( $user ) );
    15901645
    1591         $welcome_email = get_site_option( 'welcome_email' );
    15921646        if ( false == $welcome_email ) {
    1593                 /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
     1647                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
    15941648                $welcome_email = __(
    1595                         'Howdy USERNAME,
     1649'{{HEADER}}
    15961650
    1597 Your new SITE_NAME site has been successfully set up at:
    1598 BLOG_URL
     1651Your new {{SITENAME}} site has been successfully set up at:
     1652{{SITEURL}}
    15991653
    16001654You can log in to the administrator account with the following information:
    16011655
    1602 Username: USERNAME
    1603 Password: PASSWORD
    1604 Log in here: BLOG_URLwp-login.php
     1656Username: {{USERNAME}}
     1657Password: {{PASSWORD}}
    16051658
    1606 We hope you enjoy your new site. Thanks!
     1659Log in here: {{LOGINLINK}}
    16071660
    1608 --The Team @ SITE_NAME'
     1661We hope you will enjoy your new site.
     1662
     1663{{FOOTER}}'
    16091664                );
    16101665        }
    16111666
    1612         $url = get_blogaddress_by_id( $blog_id );
    1613 
    1614         $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
    1615         $welcome_email = str_replace( 'BLOG_TITLE', $title, $welcome_email );
    1616         $welcome_email = str_replace( 'BLOG_URL', $url, $welcome_email );
    1617         $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
    1618         $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
    1619 
    16201667        /**
    1621          * Filters the content of the welcome email after site activation.
     1668         * Filter removed
    16221669         *
    1623          * Content should be formatted for transmission via wp_mail().
     1670         * $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
     1671         * $subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
    16241672         *
    1625          * @since MU (3.0.0)
     1673         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    16261674         *
    1627          * @param string $welcome_email Message body of the email.
    1628          * @param int    $blog_id       Blog ID.
    1629          * @param int    $user_id       User ID.
    1630          * @param string $password      User password.
    1631          * @param string $title         Site title.
    1632          * @param array  $meta          Signup meta data. By default, contains the requested privacy setting and lang_id.
     1675         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1676         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1677         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1678         *
    16331679         */
    1634         $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
    1635         $admin_email   = get_site_option( 'admin_email' );
    16361680
    1637         if ( '' == $admin_email ) {
    1638                 $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    1639         }
     1681        $wp_mail = array(
     1682                'id' => 'update_welcome',
     1683                'group' => 'ms',
    16401684
    1641         $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    1642         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
    1643         $message         = $welcome_email;
     1685                'to' => $user->user_email,
     1686                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1687                'subject' => __( 'New {{SITENAME}} Site: {{BLOGNAME}}' ),
     1688                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1689                'message' => $welcome_email,
     1690                'headers' => array(
     1691                        'From' => "{$from_name} <{$admin_email}>",
     1692                        'Content-Type' => 'text/plain; charset="' . get_option( 'blog_charset' ) . '"',
     1693                ),
     1694                'replacements' => array(
     1695                        '{{SITENAME}}' => $current_network->site_name,
     1696                        '{{SITEURL}}'  => esc_url_raw( $url ),
     1697                        '{{USERNAME}}' => $user->user_login,
     1698                        '{{PASSWORD}}' => $password,
     1699                        '{{LOGINLINK}}' => esc_url_raw( $login_url ),
     1700                        '{{BLOGNAME}}' => wp_unslash( $title ),
     1701                ),
     1702        );
    16441703
    1645         if ( empty( $current_network->site_name ) ) {
    1646                 $current_network->site_name = 'WordPress';
    1647         }
     1704        $wp_mailer = WP_Mailer::getInstance();
     1705        $wp_mailer->send( $wp_mail );
    16481706
    1649         /* translators: New site notification email subject. 1: Network title, 2: New site title. */
    1650         $subject = __( 'New %1$s Site: %2$s' );
    1651 
    1652         /**
    1653          * Filters the subject of the welcome email after site activation.
    1654          *
    1655          * @since MU (3.0.0)
    1656          *
    1657          * @param string $subject Subject of the email.
    1658          */
    1659         $subject = apply_filters( 'update_welcome_subject', sprintf( $subject, $current_network->site_name, wp_unslash( $title ) ) );
    1660 
    1661         wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
    1662 
    16631707        if ( $switched_locale ) {
    16641708                restore_previous_locale();
    16651709        }
     
    16831727 * @return bool
    16841728 */
    16851729function wpmu_welcome_user_notification( $user_id, $password, $meta = array() ) {
    1686         $current_network = get_network();
    1687 
    16881730        /**
    16891731         * Filters whether to bypass the welcome email after user activation.
    16901732         *
     
    17001742                return false;
    17011743        }
    17021744
    1703         $welcome_email = get_site_option( 'welcome_user_email' );
     1745        $current_network = get_network();
     1746        if ( empty( $current_network->site_name ) ) {
     1747                $current_network->site_name = 'WordPress';
     1748        }
    17041749
    17051750        $user = get_userdata( $user_id );
    17061751
    1707         $switched_locale = switch_to_locale( get_user_locale( $user ) );
    1708 
    1709         /**
    1710          * Filters the content of the welcome email after user activation.
    1711          *
    1712          * Content should be formatted for transmission via wp_mail().
    1713          *
    1714          * @since MU (3.0.0)
    1715          *
    1716          * @param string $welcome_email The message body of the account activation success email.
    1717          * @param int    $user_id       User ID.
    1718          * @param string $password      User password.
    1719          * @param array  $meta          Signup meta data. Default empty array.
    1720          */
    1721         $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
    1722         $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
    1723         $welcome_email = str_replace( 'USERNAME', $user->user_login, $welcome_email );
    1724         $welcome_email = str_replace( 'PASSWORD', $password, $welcome_email );
    1725         $welcome_email = str_replace( 'LOGINLINK', wp_login_url(), $welcome_email );
    1726 
    17271752        $admin_email = get_site_option( 'admin_email' );
    1728 
    17291753        if ( '' == $admin_email ) {
    17301754                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    17311755        }
    1732 
    17331756        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    1734         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
    1735         $message         = $welcome_email;
    17361757
    1737         if ( empty( $current_network->site_name ) ) {
    1738                 $current_network->site_name = 'WordPress';
     1758        // Back-compat for pre-5.5.
     1759        $welcome_backward_compat = array( 'SITE_NAME' => '{{SITENAME}}', 'USERNAME' => '{{USERNAME}}', 'PASSWORD' => '{{PASSWORD}}', 'LOGINLINK' => '{{LOGINLINK}}', '{{{{' => '{{', '}}}}' => '}}', );
     1760        $welcome_search = array_keys( $welcome_backward_compat );
     1761        $welcome_email = get_site_option( 'welcome_user_email' );
     1762        $welcome_email = str_replace( $welcome_search, $welcome_backward_compat, $welcome_email );
     1763
     1764        $switched_locale = switch_to_locale( get_user_locale( $user ) );
     1765
     1766        if ( false == $welcome_email ) {
     1767                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1768                $welcome_email = __(
     1769'{{HEADER}}
     1770
     1771As {{USERNAME}}, your new account is set up.
     1772
     1773You can log in with the following information:
     1774Username: {{USERNAME}}
     1775Password: {{PASSWORD}}
     1776
     1777Log in here: {{LOGINLINK}}
     1778
     1779
     1780{{FOOTER}}'
     1781                );
    17391782        }
    17401783
    1741         /* translators: New user notification email subject. 1: Network title, 2: New user login. */
    1742         $subject = __( 'New %1$s User: %2$s' );
    1743 
    17441784        /**
    1745          * Filters the subject of the welcome email after user activation.
     1785         * Filter removed
    17461786         *
    1747          * @since MU (3.0.0)
     1787         * $welcome_email = apply_filters( 'update_welcome_user_email', $welcome_email, $user_id, $password, $meta );
     1788         * $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) );
    17481789         *
    1749          * @param string $subject Subject of the email.
     1790         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     1791         *
     1792         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1793         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1794         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1795         *
    17501796         */
    1751         $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) );
    17521797
    1753         wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
     1798        $wp_mail = array(
     1799                'id' => 'update_welcome_user',
     1800                'group' => 'ms',
    17541801
     1802                'to' => $user->user_email,
     1803                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1804                'subject' => __( 'New {{SITENAME}} User: {{USERNAME}}' ),
     1805                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1806                'message' => $welcome_email,
     1807                'headers' => array(
     1808                        'From' => "{$from_name} <{$admin_email}>",
     1809                        'Content-Type' => 'text/plain; charset="' . get_option( 'blog_charset' ) . '"',
     1810                ),
     1811                'replacements' => array(
     1812                        '{{SITENAME}}' => $current_network->site_name,
     1813                        '{{USERNAME}}' => $user->user_login,
     1814                        '{{PASSWORD}}' => $password,
     1815                        '{{LOGINLINK}}' => esc_url_raw( wp_login_url() ),
     1816                ),
     1817        );
     1818
     1819        $wp_mailer = WP_Mailer::getInstance();
     1820        $wp_mailer->send( $wp_mail );
     1821
    17551822        if ( $switched_locale ) {
    17561823                restore_previous_locale();
    17571824        }
     
    22762343        if ( ! $text ) {
    22772344                remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
    22782345
    2279                 /* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
     2346                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
    22802347                $text = __(
    2281                         'Howdy USERNAME,
     2348'{{HEADER}}
    22822349
    2283 Your new account is set up.
     2350As {{USERNAME}}, your new account is set up.
    22842351
    22852352You can log in with the following information:
    2286 Username: USERNAME
    2287 Password: PASSWORD
    2288 LOGINLINK
     2353Username: {{USERNAME}}
     2354Password: {{PASSWORD}}
    22892355
    2290 Thanks!
     2356Log in here: {{LOGINLINK}}
    22912357
    2292 --The Team @ SITE_NAME'
     2358
     2359{{FOOTER}}'
    22932360                );
    22942361                update_site_option( 'welcome_user_email', $text );
    22952362        }
     
    26722739
    26732740        $switched_locale = switch_to_locale( get_user_locale() );
    26742741
    2675         /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    2676         $email_text = __(
    2677                 'Howdy ###USERNAME###,
     2742        /**
     2743         * Filter removed
     2744         *
     2745         * $content = apply_filters( 'new_network_admin_email_content', $email_text, $new_admin_email );
     2746         *
     2747         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     2748         *
     2749         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2750         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2751         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2752         *
     2753         */
    26782754
    2679 You recently requested to have the network admin email address on
     2755        $wp_mail = array(
     2756                'id' => 'new_network_admin_email',
     2757                'group' => 'network',
     2758
     2759                'to' => $value,
     2760                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2761                'subject' => __( '[{{SITENAME}}] Network Admin Email Change Request' ),
     2762                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2763                'message' => __(
     2764'{{HEADER}}
     2765
     2766As {{USERNAME}}, you recently requested to have the network admin email address on
    26802767your network changed.
    26812768
    26822769If this is correct, please click on the following link to change it:
    2683 ###ADMIN_URL###
     2770{{ADMIN_URL}}
    26842771
    26852772You can safely ignore and delete this email if you do not want to
    26862773take this action.
    26872774
    2688 This email has been sent to ###EMAIL###
     2775This email has been sent to {{EMAIL}}
    26892776
    2690 Regards,
    2691 All at ###SITENAME###
    2692 ###SITEURL###'
     2777{{FOOTER}}'
     2778                ),
     2779                'replacements' => array(
     2780                        '{{SITENAME}}' => get_site_option( 'site_name' ),
     2781                        '{{SITEURL}}'  => esc_url_raw( network_home_url() ),
     2782                        '{{ADMIN_URL}}' => esc_url_raw( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ),
     2783                        '{{EMAIL}}' => $value,
     2784                ),
    26932785        );
    26942786
    2695         /**
    2696          * Filters the text of the email sent when a change of network admin email address is attempted.
    2697          *
    2698          * The following strings have a special meaning and will get replaced dynamically:
    2699          * ###USERNAME###  The current user's username.
    2700          * ###ADMIN_URL### The link to click on to confirm the email change.
    2701          * ###EMAIL###     The proposed new network admin email address.
    2702          * ###SITENAME###  The name of the network.
    2703          * ###SITEURL###   The URL to the network.
    2704          *
    2705          * @since 4.9.0
    2706          *
    2707          * @param string $email_text      Text in the email.
    2708          * @param array  $new_admin_email {
    2709          *     Data relating to the new network admin email address.
    2710          *
    2711          *     @type string $hash     The secure hash used in the confirmation link URL.
    2712          *     @type string $newemail The proposed new network admin email address.
    2713          * }
    2714          */
    2715         $content = apply_filters( 'new_network_admin_email_content', $email_text, $new_admin_email );
     2787        $wp_mailer = WP_Mailer::getInstance();
     2788        $wp_mailer->send( $wp_mail );
    27162789
    2717         $current_user = wp_get_current_user();
    2718         $content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
    2719         $content      = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );
    2720         $content      = str_replace( '###EMAIL###', $value, $content );
    2721         $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );
    2722         $content      = str_replace( '###SITEURL###', network_home_url(), $content );
    2723 
    2724         wp_mail(
    2725                 $value,
    2726                 sprintf(
    2727                         /* translators: Email change notification email subject. %s: Network title. */
    2728                         __( '[%s] Network Admin Email Change Request' ),
    2729                         wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES )
    2730                 ),
    2731                 $content
    2732         );
    2733 
    27342790        if ( $switched_locale ) {
    27352791                restore_previous_locale();
    27362792        }
     
    27702826                return;
    27712827        }
    27722828
    2773         /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
    2774         $email_change_text = __(
    2775                 'Hi,
    2776 
    2777 This notice confirms that the network admin email address was changed on ###SITENAME###.
    2778 
    2779 The new network admin email address is ###NEW_EMAIL###.
    2780 
    2781 This email has been sent to ###OLD_EMAIL###
    2782 
    2783 Regards,
    2784 All at ###SITENAME###
    2785 ###SITEURL###'
    2786         );
    2787 
    2788         $email_change_email = array(
    2789                 'to'      => $old_email,
    2790                 /* translators: Network admin email change notification email subject. %s: Network title. */
    2791                 'subject' => __( '[%s] Network Admin Email Changed' ),
    2792                 'message' => $email_change_text,
    2793                 'headers' => '',
    2794         );
    2795         // Get network name.
    2796         $network_name = wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES );
    2797 
    27982829        /**
    2799          * Filters the contents of the email notification sent when the network admin email address is changed.
     2830         * Filter removed
    28002831         *
    2801          * @since 4.9.0
     2832         * $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id );
    28022833         *
    2803          * @param array $email_change_email {
    2804          *            Used to build wp_mail().
     2834         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    28052835         *
    2806          *            @type string $to      The intended recipient.
    2807          *            @type string $subject The subject of the email.
    2808          *            @type string $message The content of the email.
    2809          *                The following strings have a special meaning and will get replaced dynamically:
    2810          *                - ###OLD_EMAIL### The old network admin email address.
    2811          *                - ###NEW_EMAIL### The new network admin email address.
    2812          *                - ###SITENAME###  The name of the network.
    2813          *                - ###SITEURL###   The URL to the site.
    2814          *            @type string $headers Headers.
    2815          *        }
    2816          * @param string $old_email  The old network admin email address.
    2817          * @param string $new_email  The new network admin email address.
    2818          * @param int    $network_id ID of the network.
     2836         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2837         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2838         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2839         *
    28192840         */
    2820         $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id );
    28212841
    2822         $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );
    2823         $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );
    2824         $email_change_email['message'] = str_replace( '###SITENAME###', $network_name, $email_change_email['message'] );
    2825         $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
     2842        $wp_mail = array(
     2843                'id' => 'network_admin_email_change',
     2844                'group' => 'network',
    28262845
    2827         wp_mail(
    2828                 $email_change_email['to'],
    2829                 sprintf(
    2830                         $email_change_email['subject'],
    2831                         $network_name
     2846                'to' => $old_email,
     2847                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2848                'subject' => __( '[{{SITENAME}}] Network Admin Email Changed' ),
     2849                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2850                'message' => __(
     2851'{{HEADER}}
     2852
     2853This notice confirms that the network admin email address was changed on {{SITENAME}}.
     2854
     2855The new network admin email address is {{NEW_EMAIL}}.
     2856
     2857This email has been sent to {{OLD_EMAIL}}.
     2858
     2859{{FOOTER}}'
    28322860                ),
    2833                 $email_change_email['message'],
    2834                 $email_change_email['headers']
     2861                'replacements' => array(
     2862                        '{{SITENAME}}'  => get_site_option( 'site_name' ),
     2863                        '{{NEW_EMAIL}}' => $new_email,
     2864                        '{{OLD_EMAIL}}' => $old_email,
     2865                ),
    28352866        );
     2867
     2868        $wp_mailer = WP_Mailer::getInstance();
     2869        $wp_mailer->send( $wp_mail );
    28362870}
  • wp-includes/pluggable.php

     
    15601560                        $emails = array_flip( $emails );
    15611561                }
    15621562
    1563                 $switched_locale = switch_to_locale( get_locale() );
    1564 
    15651563                $comment_author_domain = '';
    15661564                if ( WP_Http::is_ip_address( $comment->comment_author_IP ) ) {
    15671565                        $comment_author_domain = gethostbyaddr( $comment->comment_author_IP );
    15681566                }
    15691567
    1570                 // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
    1571                 // We want to reverse this for the plain text arena of emails.
    1572                 $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1573                 $comment_content = wp_specialchars_decode( $comment->comment_content );
     1568                $from_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) );
    15741569
     1570                $switched_locale = switch_to_locale( get_locale() );
     1571
     1572                $notify_replacements = array (
     1573                        '{{THE_TITLE}}'         => $post->post_title,
     1574
     1575                        '{{COMMENT_TYPE}}'      => __( 'comment' ),
     1576
     1577                        '{{COMMENT_AUTHOR}}'    => $comment->comment_author,
     1578                        '{{REMOTEADDR}}'        => $comment->comment_author_IP,
     1579                        '{{COMMENT_WEBSITE}}'   => esc_url_raw( $comment_author_domain ),
     1580                        '{{COMMENT_URL}}'       => esc_url_raw( $comment->comment_author_url ),
     1581                        '{{COMMENT_CONTENT}}'   => wp_specialchars_decode( $comment->comment_content ),
     1582                        '{{COMMENTS_LINK}}'     => esc_url_raw( get_permalink( $comment->comment_post_ID ) . '#comments' ),
     1583                        '{{COMMENT_LINK}}'      => esc_url_raw( get_comment_link( $comment ) ),
     1584
     1585                        '{{APPROVELINK}}'       => esc_url_raw( admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ),
     1586                        '{{SUPPRESSLINK}}'      => esc_url_raw( ( EMPTY_TRASH_DAYS ) ? admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) : admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ),
     1587                        '{{SPAMLINK}}'          => esc_url_raw( admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ),
     1588                );
     1589
     1590                $notify_message = array();
     1591                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1592                $notify_message[]  = __(
     1593'{{HEADER}}
     1594
     1595New {{COMMENT_TYPE}} on your post "{{THE_TITLE}}"
     1596
     1597Website: {{COMMENT_AUTHOR}} (IP address: {{REMOTEADDR}}, {{COMMENT_WEBSITE}})
     1598
     1599URL: {{COMMENT_URL}}
     1600
     1601Content: {{COMMENT_CONTENT}}' );
     1602
    15751603                switch ( $comment->comment_type ) {
    15761604                        case 'trackback':
    1577                                 /* translators: %s: Post title. */
    1578                                 $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n";
    1579                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1580                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1581                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1582                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1583                                 /* translators: %s: Comment text. */
    1584                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1585                                 $notify_message .= __( 'You can see all trackbacks on this post here:' ) . "\r\n";
    1586                                 /* translators: Trackback notification email subject. 1: Site title, 2: Post title. */
    1587                                 $subject = sprintf( __( '[%1$s] Trackback: "%2$s"' ), $blogname, $post->post_title );
     1605                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1606                                $notify_subject = __( '[{{SITENAME}}] Trackback: "{{THE_TITLE}}"' );
     1607
     1608                                $notify_message[] = '';
     1609                                $notify_message[] = __( 'You can see all trackbacks on this post here:' );
     1610
     1611                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1612                                $notify_replacements ['{{COMMENT_TYPE}}'] = __( 'trackback' );
    15881613                                break;
    15891614
    15901615                        case 'pingback':
    1591                                 /* translators: %s: Post title. */
    1592                                 $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n";
    1593                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1594                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1595                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1596                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1597                                 /* translators: %s: Comment text. */
    1598                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1599                                 $notify_message .= __( 'You can see all pingbacks on this post here:' ) . "\r\n";
    1600                                 /* translators: Pingback notification email subject. 1: Site title, 2: Post title. */
    1601                                 $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title );
     1616                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1617                                $notify_subject = __( '[{{SITENAME}}] Pingback: "{{THE_TITLE}}"' );
     1618
     1619                                $notify_message[] = '';
     1620                                $notify_message[] = __( 'You can see all pingbacks on this post here:' );
     1621
     1622                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1623                                $notify_replacements ['{{COMMENT_TYPE}}'] = __( 'pingback' );
    16021624                                break;
    16031625
    16041626                        default: // Comments.
    1605                                 /* translators: %s: Post title. */
    1606                                 $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n";
    1607                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1608                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1609                                 /* translators: %s: Comment author email. */
    1610                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1611                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1612                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    16131627
    1614                                 if ( $comment->comment_parent && user_can( $post->post_author, 'edit_comment', $comment->comment_parent ) ) {
    1615                                         /* translators: Comment moderation. %s: Parent comment edit URL. */
    1616                                         $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
     1628                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1629                                $notify_subject = __( '[{{SITENAME}}] Comment: "{{THE_TITLE}}"' );
     1630
     1631                                $notify_message = array();
     1632                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1633                                $notify_message[]  = __(
     1634'{{HEADER}}
     1635
     1636New {{COMMENT_TYPE}} on your post "{{THE_TITLE}}"
     1637
     1638Website: {{COMMENT_AUTHOR}} (IP address: {{REMOTEADDR}}, {{COMMENT_WEBSITE}})
     1639
     1640Email: {{COMMENT_EMAIL}}
     1641URL: {{COMMENT_URL}}' );
     1642                                $notify_replacements ['{{COMMENT_EMAIL}}'] = $comment->comment_author_email;
     1643
     1644                                if ( $comment->comment_parent ) {
     1645                                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1646                                        $notify_message[] =  __( 'In reply to: {{ADMINURL}}' );
     1647                                        $notify_replacements ['{{ADMINURL}}'] = esc_url_raw( admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) );
    16171648                                }
    16181649
    1619                                 /* translators: %s: Comment text. */
    1620                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
    1621                                 $notify_message .= __( 'You can see all comments on this post here:' ) . "\r\n";
    1622                                 /* translators: Comment notification email subject. 1: Site title, 2: Post title. */
    1623                                 $subject = sprintf( __( '[%1$s] Comment: "%2$s"' ), $blogname, $post->post_title );
     1650                                $notify_message[] = '';
     1651                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1652                                $notify_message[] = __( 'Comment: {{COMMENT_CONTENT}}' );
     1653                                $notify_message[] = '';
     1654                                $notify_message[] = __( 'You can see all comments on this post here:' );
    16241655                                break;
    16251656                }
    16261657
    1627                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "#comments\r\n\r\n";
    1628                 /* translators: %s: Comment URL. */
    1629                 $notify_message .= sprintf( __( 'Permalink: %s' ), get_comment_link( $comment ) ) . "\r\n";
    16301658
     1659                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1660                $notify_message[] = '{{COMMENTS_LINK}}';
     1661                $notify_message[] = '';
     1662                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1663                $notify_message[] = __( 'Permalink: {{COMMENT_LINK}}' );
     1664
    16311665                if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) {
     1666
    16321667                        if ( EMPTY_TRASH_DAYS ) {
    1633                                 /* translators: Comment moderation. %s: Comment action URL. */
    1634                                 $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
     1668                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1669                                $notify_message[] = __( 'Trash it: {{SUPPRESSLINK}}' );
    16351670                        } else {
    1636                                 /* translators: Comment moderation. %s: Comment action URL. */
    1637                                 $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
     1671                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1672                                $notify_message[] = __( 'Delete it: {{SUPPRESSLINK}}' );
    16381673                        }
    1639                         /* translators: Comment moderation. %s: Comment action URL. */
    1640                         $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment->comment_ID}#wpbody-content" ) ) . "\r\n";
    1641                 }
    16421674
    1643                 $wp_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) );
    1644 
    1645                 if ( '' == $comment->comment_author ) {
    1646                         $from = "From: \"$blogname\" <$wp_email>";
    1647                         if ( '' != $comment->comment_author_email ) {
    1648                                 $reply_to = "Reply-To: $comment->comment_author_email";
    1649                         }
    1650                 } else {
    1651                         $from = "From: \"$comment->comment_author\" <$wp_email>";
    1652                         if ( '' != $comment->comment_author_email ) {
    1653                                 $reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
    1654                         }
     1675                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1676                        $notify_message[] = __( 'Spam it: {{SPAMLINK}}' );
    16551677                }
    16561678
    1657                 $message_headers = "$from\n"
    1658                 . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
     1679                $notify_message[] = '';
     1680                $notify_message[] = '{{FOOTER}}';
    16591681
    1660                 if ( isset( $reply_to ) ) {
    1661                         $message_headers .= $reply_to . "\n";
    1662                 }
    16631682
    1664                 /**
    1665                  * Filters the comment notification email text.
    1666                  *
    1667                  * @since 1.5.2
    1668                  *
    1669                  * @param string $notify_message The comment notification email text.
    1670                  * @param int    $comment_id     Comment ID.
    1671                  */
    1672                 $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID );
    16731683
    16741684                /**
    1675                  * Filters the comment notification email subject.
     1685                 * Filter removed
    16761686                 *
    1677                  * @since 1.5.2
     1687                 * $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID );
     1688                 * $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID );
     1689                 * $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID );
    16781690                 *
    1679                  * @param string $subject    The comment notification email subject.
    1680                  * @param int    $comment_id Comment ID.
    1681                  */
    1682                 $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID );
    1683 
    1684                 /**
    1685                  * Filters the comment notification email headers.
     1691                 * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    16861692                 *
    1687                  * @since 1.5.2
     1693                 *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1694                 *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1695                 *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    16881696                 *
    1689                  * @param string $message_headers Headers for the comment notification email.
    1690                  * @param int    $comment_id      Comment ID.
    16911697                 */
    1692                 $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID );
    16931698
    1694                 foreach ( $emails as $email ) {
    1695                         wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
     1699                $from_email = 'wordpress@' . preg_replace( '#^www\.#', '', strtolower( $_SERVER['SERVER_NAME'] ) );
     1700
     1701                $wp_mail = array(
     1702                        'id' => 'comment_notification',
     1703                        'group' => 'blog',
     1704
     1705                        'to' => $emails,
     1706                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1707                        'subject' => $notify_subject,
     1708                        'message' => implode( "\r\n", $notify_message ),
     1709                        'headers' => array(
     1710                                'From' => ( '' == $comment->comment_author ) ? "{$blogname} <{$from_email}>" : "{$comment->comment_author} <{$from_email}>",
     1711                                'Content-Type' => 'text/plain; charset="' . get_option( 'blog_charset' ) . '"',
     1712                        ),
     1713                        'replacements' => $notify_replacements,
     1714                );
     1715
     1716                if ( '' != $comment->comment_author_email ) {
     1717                        $wp_mail['headers']['Reply-To'] =  "{$comment->comment_author_email} <{$comment->comment_author_email}>";
    16961718                }
    16971719
     1720                $wp_mailer = WP_Mailer::getInstance();
     1721                $wp_mailer->send( $wp_mail );
     1722
    16981723                if ( $switched_locale ) {
    16991724                        restore_previous_locale();
    17001725                }
     
    17471772                        }
    17481773                }
    17491774
     1775                /**
     1776                 * Filters the list of recipients for comment moderation emails.
     1777                 *
     1778                 * @since 3.7.0
     1779                 *
     1780                 * @param string[] $emails     List of email addresses to notify for comment moderation.
     1781                 * @param int      $comment_id Comment ID.
     1782                 */
     1783                $emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id );
     1784
    17501785                $switched_locale = switch_to_locale( get_locale() );
    17511786
    17521787                $comment_author_domain = '';
     
    17561791
    17571792                $comments_waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" );
    17581793
    1759                 // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
    1760                 // We want to reverse this for the plain text arena of emails.
    1761                 $blogname        = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1762                 $comment_content = wp_specialchars_decode( $comment->comment_content );
     1794                $notify_replacements = array (
     1795                        '{{THE_TITLE}}'         => $post->post_title,
    17631796
     1797                        '{{COMMENT_TYPE}}'      => __( 'comment' ),
     1798
     1799                        '{{COMMENT_AUTHOR}}'    => $comment->comment_author,
     1800                        '{{REMOTEADDR}}'        => $comment->comment_author_IP,
     1801                        '{{COMMENT_WEBSITE}}'   => esc_url_raw( $comment_author_domain ),
     1802                        '{{COMMENT_URL}}'       => esc_url_raw( $comment->comment_author_url ),
     1803                        '{{COMMENT_CONTENT}}'   => wp_specialchars_decode( $comment->comment_content ),
     1804                        '{{COMMENT_LINK}}'      => esc_url_raw( get_permalink( $comment->comment_post_ID ) ),
     1805
     1806                        '{{APPROVELINK}}'       => esc_url_raw( admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ),
     1807                        '{{SUPPRESSLINK}}'      => esc_url_raw( ( EMPTY_TRASH_DAYS ) ? admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) : admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ),
     1808                        '{{SPAMLINK}}'          => esc_url_raw( admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ),
     1809                );
     1810
     1811                $notify_message = array();
     1812                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1813                $notify_message[]  = __(
     1814'{{HEADER}}
     1815
     1816A new {{COMMENT_TYPE}} on the post "{{THE_TITLE}}" is waiting for your approval
     1817{{COMMENT_LINK}}
     1818
     1819Website: {{COMMENT_AUTHOR}} (IP address: {{REMOTEADDR}}, {{COMMENT_WEBSITE}})
     1820
     1821URL: {{COMMENT_URL}}
     1822
     1823Content: {{COMMENT_CONTENT}}' );
     1824
    17641825                switch ( $comment->comment_type ) {
    17651826                        case 'trackback':
    1766                                 /* translators: %s: Post title. */
    1767                                 $notify_message  = sprintf( __( 'A new trackback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1768                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1769                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1770                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1771                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1772                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1773                                 $notify_message .= __( 'Trackback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
     1827                                $notify_replacements ['{{COMMENT_TYPE}}'] = __( 'trackback' );
    17741828                                break;
    17751829
    17761830                        case 'pingback':
    1777                                 /* translators: %s: Post title. */
    1778                                 $notify_message  = sprintf( __( 'A new pingback on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1779                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1780                                 /* translators: 1: Trackback/pingback website name, 2: Website IP address, 3: Website hostname. */
    1781                                 $notify_message .= sprintf( __( 'Website: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1782                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1783                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
    1784                                 $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n";
     1831                                $notify_replacements ['{{COMMENT_TYPE}}'] = __( 'pingback' );
    17851832                                break;
    17861833
    17871834                        default: // Comments.
    1788                                 /* translators: %s: Post title. */
    1789                                 $notify_message  = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n";
    1790                                 $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n";
    1791                                 /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */
    1792                                 $notify_message .= sprintf( __( 'Author: %1$s (IP address: %2$s, %3$s)' ), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n";
    1793                                 /* translators: %s: Comment author email. */
    1794                                 $notify_message .= sprintf( __( 'Email: %s' ), $comment->comment_author_email ) . "\r\n";
    1795                                 /* translators: %s: Trackback/pingback/comment author URL. */
    1796                                 $notify_message .= sprintf( __( 'URL: %s' ), $comment->comment_author_url ) . "\r\n";
     1835                                $notify_message = array();
     1836                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1837                                $notify_message[]  = __(
     1838'{{HEADER}}
    17971839
     1840A new {{COMMENT_TYPE}} on the post "{{THE_TITLE}}" is waiting for your approval
     1841{{APPROVELINK}}
     1842
     1843Website: {{COMMENT_AUTHOR}} (IP address: {{REMOTEADDR}}, {{COMMENT_WEBSITE}})
     1844
     1845Email: {{COMMENT_EMAIL}}
     1846URL: {{COMMENT_URL}}' );
     1847                                $notify_replacements ['{{COMMENT_EMAIL}}'] = $comment->comment_author_email;
     1848
    17981849                                if ( $comment->comment_parent ) {
    1799                                         /* translators: Comment moderation. %s: Parent comment edit URL. */
    1800                                         $notify_message .= sprintf( __( 'In reply to: %s' ), admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) ) . "\r\n";
     1850                                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1851                                        $notify_message[] =  __( 'In reply to: {{ADMINURL}}' ) . "\r\n";
     1852                                        $notify_replacements ['{{ADMINURL}}'] = esc_url_raw( admin_url( "comment.php?action=editcomment&c={$comment->comment_parent}#wpbody-content" ) );
    18011853                                }
    18021854
    1803                                 /* translators: %s: Comment text. */
    1804                                 $notify_message .= sprintf( __( 'Comment: %s' ), "\r\n" . $comment_content ) . "\r\n\r\n";
     1855                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1856                                $notify_message[] = __( 'Comment: {{COMMENT_CONTENT}}' );
     1857                                $notify_message[] = '';
    18051858                                break;
    18061859                }
    18071860
    1808                 /* translators: Comment moderation. %s: Comment action URL. */
    1809                 $notify_message .= sprintf( __( 'Approve it: %s' ), admin_url( "comment.php?action=approve&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     1861                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1862                $notify_message[] = __( 'Approve it: {{APPROVELINK}}' );
    18101863
    18111864                if ( EMPTY_TRASH_DAYS ) {
    1812                         /* translators: Comment moderation. %s: Comment action URL. */
    1813                         $notify_message .= sprintf( __( 'Trash it: %s' ), admin_url( "comment.php?action=trash&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     1865                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1866                        $notify_message[] = __( 'Trash it: {{SUPPRESSLINK}}' );
    18141867                } else {
    1815                         /* translators: Comment moderation. %s: Comment action URL. */
    1816                         $notify_message .= sprintf( __( 'Delete it: %s' ), admin_url( "comment.php?action=delete&c={$comment_id}#wpbody-content" ) ) . "\r\n";
     1868                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1869                        $notify_message[] = __( 'Delete it: {{SUPPRESSLINK}}' );
    18171870                }
    18181871
    1819                 /* translators: Comment moderation. %s: Comment action URL. */
    1820                 $notify_message .= sprintf( __( 'Spam it: %s' ), admin_url( "comment.php?action=spam&c={$comment_id}#wpbody-content" ) ) . "\r\n";
    1821 
    1822                 $notify_message .= sprintf(
     1872                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1873                $notify_message[] = __( 'Spam it: {{SPAMLINK}}' );
     1874                $notify_message[] = '';
     1875                $notify_message[] = sprintf(
    18231876                        /* translators: Comment moderation. %s: Number of comments awaiting approval. */
    18241877                        _n(
    18251878                                'Currently %s comment is waiting for approval. Please visit the moderation panel:',
     
    18271880                                $comments_waiting
    18281881                        ),
    18291882                        number_format_i18n( $comments_waiting )
    1830                 ) . "\r\n";
    1831                 $notify_message .= admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' ) . "\r\n";
    1832 
    1833                 /* translators: Comment moderation notification email subject. 1: Site title, 2: Post title. */
    1834                 $subject         = sprintf( __( '[%1$s] Please moderate: "%2$s"' ), $blogname, $post->post_title );
    1835                 $message_headers = '';
    1836 
     1883                );
     1884                $notify_message[] = admin_url( 'edit-comments.php?comment_status=moderated#wpbody-content' );
     1885                $notify_message[] = '';
     1886                $notify_message[] = '{{FOOTER}}';
     1887               
    18371888                /**
    1838                  * Filters the list of recipients for comment moderation emails.
     1889                 * Filters removed
    18391890                 *
    1840                  * @since 3.7.0
     1891                 * $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id );
     1892                 * $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id );
     1893                 * $message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id );
    18411894                 *
    1842                  * @param string[] $emails     List of email addresses to notify for comment moderation.
    1843                  * @param int      $comment_id Comment ID.
    1844                  */
    1845                 $emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id );
    1846 
    1847                 /**
    1848                  * Filters the comment moderation email text.
     1895                 * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    18491896                 *
    1850                  * @since 1.5.2
     1897                 *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1898                 *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1899                 *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    18511900                 *
    1852                  * @param string $notify_message Text of the comment moderation email.
    1853                  * @param int    $comment_id     Comment ID.
    18541901                 */
    1855                 $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id );
    18561902
    1857                 /**
    1858                  * Filters the comment moderation email subject.
    1859                  *
    1860                  * @since 1.5.2
    1861                  *
    1862                  * @param string $subject    Subject of the comment moderation email.
    1863                  * @param int    $comment_id Comment ID.
    1864                  */
    1865                 $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id );
     1903                $wp_mail = array(
     1904                        'id' => 'comment_moderation',
     1905                        'group' => 'blog',
    18661906
    1867                 /**
    1868                  * Filters the comment moderation email headers.
    1869                  *
    1870                  * @since 2.8.0
    1871                  *
    1872                  * @param string $message_headers Headers for the comment moderation email.
    1873                  * @param int    $comment_id      Comment ID.
    1874                  */
    1875                 $message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id );
     1907                        'to' => $emails,
     1908                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1909                        'subject' => __( '[{{SITENAME}}] Please moderate: "{{THE_TITLE}}"' ),
     1910                        'message' => implode( "\r\n", $notify_message ),
     1911                        'replacements' => $notify_replacements,
     1912                );
    18761913
    1877                 foreach ( $emails as $email ) {
    1878                         wp_mail( $email, wp_specialchars_decode( $subject ), $notify_message, $message_headers );
    1879                 }
     1914                $wp_mailer = WP_Mailer::getInstance();
     1915                $wp_mailer->send( $wp_mail );
    18801916
    18811917                if ( $switched_locale ) {
    18821918                        restore_previous_locale();
     
    18981934                // Send a copy of password change notification to the admin,
    18991935                // but check to see if it's the admin whose password we're changing, and skip this.
    19001936                if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) {
    1901                         /* translators: %s: User name. */
    1902                         $message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n";
    1903                         // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
    1904                         // We want to reverse this for the plain text arena of emails.
    1905                         $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1906 
    1907                         $wp_password_change_notification_email = array(
    1908                                 'to'      => get_option( 'admin_email' ),
    1909                                 /* translators: Password change notification email subject. %s: Site title. */
    1910                                 'subject' => __( '[%s] Password Changed' ),
    1911                                 'message' => $message,
    1912                                 'headers' => '',
    1913                         );
    1914 
     1937                       
    19151938                        /**
    1916                          * Filters the contents of the password change notification email sent to the site admin.
     1939                         * Filter removed
    19171940                         *
    1918                          * @since 4.9.0
     1941                         * $wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname );
    19191942                         *
    1920                          * @param array   $wp_password_change_notification_email {
    1921                          *     Used to build wp_mail().
     1943                         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    19221944                         *
    1923                          *     @type string $to      The intended recipient - site admin email address.
    1924                          *     @type string $subject The subject of the email.
    1925                          *     @type string $message The body of the email.
    1926                          *     @type string $headers The headers of the email.
    1927                          * }
    1928                          * @param WP_User $user     User object for user whose password was changed.
    1929                          * @param string  $blogname The site title.
     1945                         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     1946                         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     1947                         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     1948                         *
    19301949                         */
    1931                         $wp_password_change_notification_email = apply_filters( 'wp_password_change_notification_email', $wp_password_change_notification_email, $user, $blogname );
    19321950
    1933                         wp_mail(
    1934                                 $wp_password_change_notification_email['to'],
    1935                                 wp_specialchars_decode( sprintf( $wp_password_change_notification_email['subject'], $blogname ) ),
    1936                                 $wp_password_change_notification_email['message'],
    1937                                 $wp_password_change_notification_email['headers']
     1951                        $wp_mail = array(
     1952                                'id' => 'wp_password_change_notification',
     1953                                'group' => 'admin',
     1954
     1955                                'to' => get_option( 'admin_email' ),
     1956                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1957                                'subject' => __( '[{{SITENAME}}] Password Changed' ),
     1958                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     1959                                'message' => __(
     1960'{{HEADER}}
     1961
     1962Password changed for user: {{USERNAME}}
     1963
     1964{{FOOTER}}'
     1965                                ),
     1966                                'replacements' => array(
     1967                                        '{{USERNAME}}' => $user->user_login,
     1968                                ),
    19381969                        );
     1970
     1971                        $wp_mailer = WP_Mailer::getInstance();
     1972                        $wp_mailer->send( $wp_mail );
     1973
    19391974                }
    19401975        }
    19411976endif;
     
    19682003
    19692004                $user = get_userdata( $user_id );
    19702005
    1971                 // The blogname option is escaped with esc_html() on the way into the database in sanitize_option().
    1972                 // We want to reverse this for the plain text arena of emails.
    1973                 $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    1974 
    19752006                if ( 'user' !== $notify ) {
    19762007                        $switched_locale = switch_to_locale( get_locale() );
    19772008
    1978                         /* translators: %s: Site title. */
    1979                         $message = sprintf( __( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n";
    1980                         /* translators: %s: User login. */
    1981                         $message .= sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
    1982                         /* translators: %s: User email address. */
    1983                         $message .= sprintf( __( 'Email: %s' ), $user->user_email ) . "\r\n";
    1984 
    1985                         $wp_new_user_notification_email_admin = array(
    1986                                 'to'      => get_option( 'admin_email' ),
    1987                                 /* translators: New user registration notification email subject. %s: Site title. */
    1988                                 'subject' => __( '[%s] New User Registration' ),
    1989                                 'message' => $message,
    1990                                 'headers' => '',
    1991                         );
    1992 
    19932009                        /**
    1994                          * Filters the contents of the new user notification email sent to the site admin.
     2010                         * Filter removed
    19952011                         *
    1996                          * @since 4.9.0
     2012                         * $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
    19972013                         *
    1998                          * @param array   $wp_new_user_notification_email_admin {
    1999                          *     Used to build wp_mail().
     2014                         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    20002015                         *
    2001                          *     @type string $to      The intended recipient - site admin email address.
    2002                          *     @type string $subject The subject of the email.
    2003                          *     @type string $message The body of the email.
    2004                          *     @type string $headers The headers of the email.
    2005                          * }
    2006                          * @param WP_User $user     User object for new user.
    2007                          * @param string  $blogname The site title.
     2016                         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2017                         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2018                         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2019                         *
    20082020                         */
    2009                         $wp_new_user_notification_email_admin = apply_filters( 'wp_new_user_notification_email_admin', $wp_new_user_notification_email_admin, $user, $blogname );
    20102021
    2011                         wp_mail(
    2012                                 $wp_new_user_notification_email_admin['to'],
    2013                                 wp_specialchars_decode( sprintf( $wp_new_user_notification_email_admin['subject'], $blogname ) ),
    2014                                 $wp_new_user_notification_email_admin['message'],
    2015                                 $wp_new_user_notification_email_admin['headers']
     2022                        $wp_mail = array(
     2023                                'id' => 'new_user_notification',
     2024                                'group' => 'admin',
     2025
     2026                                'to' => get_option( 'admin_email' ),
     2027                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2028                                'subject' => __( '[{{SITENAME}}] New User Registration' ),
     2029                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2030                                'message' => __(
     2031'{{HEADER}}
     2032
     2033New user registration on your site {{SITENAME}}:
     2034
     2035Username: {{USERNAME}}
     2036
     2037Email: {{EMAIL}}
     2038
     2039{{FOOTER}}'
     2040                                ),
     2041                                'replacements' => array(
     2042                                        '{{USERNAME}}' => $user->user_login,
     2043                                        '{{EMAIL}}' => $user->user_email,
     2044                                ),
    20162045                        );
    20172046
     2047                        $wp_mailer = WP_Mailer::getInstance();
     2048                        $wp_mailer->send( $wp_mail );
     2049
    20182050                        if ( $switched_locale ) {
    20192051                                restore_previous_locale();
    20202052                        }
     
    20312063                }
    20322064
    20332065                $switched_locale = switch_to_locale( get_user_locale( $user ) );
    2034 
    2035                 /* translators: %s: User login. */
    2036                 $message  = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n";
    2037                 $message .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n";
    2038                 $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . "\r\n\r\n";
    2039 
    2040                 $message .= wp_login_url() . "\r\n";
    2041 
    2042                 $wp_new_user_notification_email = array(
    2043                         'to'      => $user->user_email,
    2044                         /* translators: Login details notification email subject. %s: Site title. */
    2045                         'subject' => __( '[%s] Login Details' ),
    2046                         'message' => $message,
    2047                         'headers' => '',
    2048                 );
    2049 
     2066               
    20502067                /**
    2051                  * Filters the contents of the new user notification email sent to the new user.
     2068                 * Filter removed
    20522069                 *
    2053                  * @since 4.9.0
     2070                 * $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname );
    20542071                 *
    2055                  * @param array   $wp_new_user_notification_email {
    2056                  *     Used to build wp_mail().
     2072                 * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    20572073                 *
    2058                  *     @type string $to      The intended recipient - New user email address.
    2059                  *     @type string $subject The subject of the email.
    2060                  *     @type string $message The body of the email.
    2061                  *     @type string $headers The headers of the email.
    2062                  * }
    2063                  * @param WP_User $user     User object for new user.
    2064                  * @param string  $blogname The site title.
     2074                 *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2075                 *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2076                 *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2077                 *
    20652078                 */
    2066                 $wp_new_user_notification_email = apply_filters( 'wp_new_user_notification_email', $wp_new_user_notification_email, $user, $blogname );
    20672079
    2068                 wp_mail(
    2069                         $wp_new_user_notification_email['to'],
    2070                         wp_specialchars_decode( sprintf( $wp_new_user_notification_email['subject'], $blogname ) ),
    2071                         $wp_new_user_notification_email['message'],
    2072                         $wp_new_user_notification_email['headers']
     2080                $wp_mail = array(
     2081                        'id' => 'new_user',
     2082                        'group' => 'blog',
     2083
     2084                        'to' => $user->user_email,
     2085                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2086                        'subject' => __( '[{{SITENAME}}] Login Details' ),
     2087                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2088                        'message' => __(
     2089'{{HEADER}}
     2090
     2091Username: {{USERNAME}}
     2092
     2093To set your password, visit the following address:
     2094{{PASSWORDLINK}}
     2095
     2096{{LOGINLINK}}
     2097
     2098{{FOOTER}}'
     2099                        ),
     2100                        'replacements' => array(
     2101                                '{{USERNAME}}' => $user->user_login,
     2102                                '{{PASSWORDLINK}}' => esc_url_raw( network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) ),
     2103                                '{{LOGINLINK}}' => esc_url_raw( wp_login_url() ),
     2104                        ),
    20732105                );
    20742106
     2107                $wp_mailer = WP_Mailer::getInstance();
     2108                $wp_mailer->send( $wp_mail );
    20752109                if ( $switched_locale ) {
    20762110                        restore_previous_locale();
    20772111                }
  • wp-includes/user.php

     
    19961996
    19971997        if ( ! is_wp_error( $user_id ) ) {
    19981998
    1999                 $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    2000 
    20011999                $switched_locale = false;
    20022000                if ( ! empty( $send_password_change_email ) || ! empty( $send_email_change_email ) ) {
    20032001                        $switched_locale = switch_to_locale( get_user_locale( $user_id ) );
     
    20042002                }
    20052003
    20062004                if ( ! empty( $send_password_change_email ) ) {
    2007                         /* translators: Do not translate USERNAME, ADMIN_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    2008                         $pass_change_text = __(
    2009                                 'Hi ###USERNAME###,
    20102005
    2011 This notice confirms that your password was changed on ###SITENAME###.
     2006                        /**
     2007                         * Filter removed
     2008                         *
     2009                         * $pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
     2010                         *
     2011                         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     2012                         *
     2013                         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2014                         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2015                         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2016                         *
     2017                         */
    20122018
     2019                        $wp_mail = array(
     2020                                'id' => 'password_change',
     2021                                'group' => 'blog',
     2022
     2023                                'to' => $user['user_email'],
     2024                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2025                                'subject' => __( '[{{SITENAME}}] Password Changed' ),
     2026                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2027                                'message' => __(
     2028'{{HEADER}}
     2029
     2030As {{USERNAME}}, this notice confirms that your password was changed on {{SITENAME}}.
     2031
    20132032If you did not change your password, please contact the Site Administrator at
    2014 ###ADMIN_EMAIL###
     2033{{ADMIN_EMAIL}}
    20152034
    2016 This email has been sent to ###EMAIL###
     2035This email has been sent to {{EMAIL}}
    20172036
    2018 Regards,
    2019 All at ###SITENAME###
    2020 ###SITEURL###'
     2037{{FOOTER}}'
     2038                                ),
     2039                                'replacements' => array(
     2040                                        '{{USERNAME}}'  => $user['user_login'],
     2041                                        '{{ADMIN_EMAIL}}' => get_option( 'admin_email' ),
     2042                                        '{{EMAIL}}'     => $user['user_email'],
     2043                                ),
    20212044                        );
    20222045
    2023                         $pass_change_email = array(
    2024                                 'to'      => $user['user_email'],
    2025                                 /* translators: Password change notification email subject. %s: Site title. */
    2026                                 'subject' => __( '[%s] Password Changed' ),
    2027                                 'message' => $pass_change_text,
    2028                                 'headers' => '',
    2029                         );
     2046                        $wp_mailer = WP_Mailer::getInstance();
     2047                        $wp_mailer->send( $wp_mail );
     2048                }
    20302049
     2050                if ( ! empty( $send_email_change_email ) ) {
     2051
    20312052                        /**
    2032                          * Filters the contents of the email sent when the user's password is changed.
     2053                         * Filters removed
    20332054                         *
    2034                          * @since 4.3.0
     2055                         * $email_change_email = apply_filters( 'email_change_email', $email_change_email, $user, $userdata );
    20352056                         *
    2036                          * @param array $pass_change_email {
    2037                          *            Used to build wp_mail().
    2038                          *            @type string $to      The intended recipients. Add emails in a comma separated string.
    2039                          *            @type string $subject The subject of the email.
    2040                          *            @type string $message The content of the email.
    2041                          *                The following strings have a special meaning and will get replaced dynamically:
    2042                          *                - ###USERNAME###    The current user's username.
    2043                          *                - ###ADMIN_EMAIL### The admin email in case this was unexpected.
    2044                          *                - ###EMAIL###       The user's email address.
    2045                          *                - ###SITENAME###    The name of the site.
    2046                          *                - ###SITEURL###     The URL to the site.
    2047                          *            @type string $headers Headers. Add headers in a newline (\r\n) separated string.
    2048                          *        }
    2049                          * @param array $user     The original user array.
    2050                          * @param array $userdata The updated user array.
     2057                         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     2058                         *
     2059                         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2060                         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2061                         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2062                         *
    20512063                         */
    2052                         $pass_change_email = apply_filters( 'password_change_email', $pass_change_email, $user, $userdata );
    20532064
    2054                         $pass_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $pass_change_email['message'] );
    2055                         $pass_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $pass_change_email['message'] );
    2056                         $pass_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $pass_change_email['message'] );
    2057                         $pass_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $pass_change_email['message'] );
    2058                         $pass_change_email['message'] = str_replace( '###SITEURL###', home_url(), $pass_change_email['message'] );
     2065                        $wp_mail = array(
     2066                                'id' => 'email_change',
     2067                                'group' => 'blog',
    20592068
    2060                         wp_mail( $pass_change_email['to'], sprintf( $pass_change_email['subject'], $blog_name ), $pass_change_email['message'], $pass_change_email['headers'] );
    2061                 }
     2069                                'to' => $user['user_email'],
     2070                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2071                                'subject' => __( '[{{SITENAME}}] Email Changed' ),
     2072                                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2073                                'message' => __(
     2074'{{HEADER}}
    20622075
    2063                 if ( ! empty( $send_email_change_email ) ) {
    2064                         /* translators: Do not translate USERNAME, ADMIN_EMAIL, NEW_EMAIL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    2065                         $email_change_text = __(
    2066                                 'Hi ###USERNAME###,
     2076As {{USERNAME}}, this notice confirms that your email address was changed on {{SITENAME}} to {{NEW_EMAIL}}.
    20672077
    2068 This notice confirms that your email address on ###SITENAME### was changed to ###NEW_EMAIL###.
     2078If you did not change your password, please contact the Site Administrator at
     2079{{ADMIN_EMAIL}}
    20692080
    2070 If you did not change your email, please contact the Site Administrator at
    2071 ###ADMIN_EMAIL###
     2081This email has been sent to {{EMAIL}}
    20722082
    2073 This email has been sent to ###EMAIL###
    2074 
    2075 Regards,
    2076 All at ###SITENAME###
    2077 ###SITEURL###'
     2083{{FOOTER}}'
     2084                                ),
     2085                                'replacements' => array(
     2086                                        '{{USERNAME}}'  => $user['user_login'],
     2087                                        '{{ADMIN_EMAIL}}' => get_option( 'admin_email' ),
     2088                                        '{{EMAIL}}'     => $user['user_email'],
     2089                                        '{{NEW_EMAIL}}' => $userdata['user_email'],
     2090                                ),
    20782091                        );
    20792092
    2080                         $email_change_email = array(
    2081                                 'to'      => $user['user_email'],
    2082                                 /* translators: Email change notification email subject. %s: Site title. */
    2083                                 'subject' => __( '[%s] Email Changed' ),
    2084                                 'message' => $email_change_text,
    2085                                 'headers' => '',
    2086                         );
    2087 
    2088                         /**
    2089                          * Filters the contents of the email sent when the user's email is changed.
    2090                          *
    2091                          * @since 4.3.0
    2092                          *
    2093                          * @param array $email_change_email {
    2094                          *            Used to build wp_mail().
    2095                          *            @type string $to      The intended recipients.
    2096                          *            @type string $subject The subject of the email.
    2097                          *            @type string $message The content of the email.
    2098                          *                The following strings have a special meaning and will get replaced dynamically:
    2099                          *                - ###USERNAME###    The current user's username.
    2100                          *                - ###ADMIN_EMAIL### The admin email in case this was unexpected.
    2101                          *                - ###NEW_EMAIL###   The new email address.
    2102                          *                - ###EMAIL###       The old email address.
    2103                          *                - ###SITENAME###    The name of the site.
    2104                          *                - ###SITEURL###     The URL to the site.
    2105                          *            @type string $headers Headers.
    2106                          *        }
    2107                          * @param array $user The original user array.
    2108                          * @param array $userdata The updated user array.
    2109                          */
    2110                         $email_change_email = apply_filters( 'email_change_email', $email_change_email, $user, $userdata );
    2111 
    2112                         $email_change_email['message'] = str_replace( '###USERNAME###', $user['user_login'], $email_change_email['message'] );
    2113                         $email_change_email['message'] = str_replace( '###ADMIN_EMAIL###', get_option( 'admin_email' ), $email_change_email['message'] );
    2114                         $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $userdata['user_email'], $email_change_email['message'] );
    2115                         $email_change_email['message'] = str_replace( '###EMAIL###', $user['user_email'], $email_change_email['message'] );
    2116                         $email_change_email['message'] = str_replace( '###SITENAME###', $blog_name, $email_change_email['message'] );
    2117                         $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
    2118 
    2119                         wp_mail( $email_change_email['to'], sprintf( $email_change_email['subject'], $blog_name ), $email_change_email['message'], $email_change_email['headers'] );
     2093                        $wp_mailer = WP_Mailer::getInstance();
     2094                        $wp_mailer->send( $wp_mail );
    21202095                }
    21212096
    21222097                if ( $switched_locale ) {
     
    28292804                );
    28302805                update_user_meta( $current_user->ID, '_new_email', $new_user_email );
    28312806
    2832                 $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     2807                /**
     2808                 * Filters removed
     2809                 *
     2810                 * $content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
     2811                 *
     2812                 * all mails components are filterable using wp-includes/class-wp-mailer.php filters
     2813                 *
     2814                 *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     2815                 *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     2816                 *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     2817                 *
     2818                 */
    28332819
    2834                 /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    2835                 $email_text = __(
    2836                         'Howdy ###USERNAME###,
     2820                $wp_mail = array(
     2821                        'id' => 'new_user_email',
     2822                        'group' => 'blog',
    28372823
    2838 You recently requested to have the email address on your account changed.
     2824                        'to' => $_POST['email'],
     2825                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2826                        'subject' => __( '[{{SITENAME}}] Email Change Request' ),
     2827                        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     2828                        'message' => __(
     2829'{{HEADER}}
    28392830
     2831As {{USERNAME}}, you recently requested to have the email address on your account changed.
     2832
    28402833If this is correct, please click on the following link to change it:
    2841 ###ADMIN_URL###
     2834{{ADMIN_URL}}
    28422835
    28432836You can safely ignore and delete this email if you do not want to
    28442837take this action.
    28452838
    2846 This email has been sent to ###EMAIL###
     2839This email has been sent to {{EMAIL}}
    28472840
    2848 Regards,
    2849 All at ###SITENAME###
    2850 ###SITEURL###'
     2841{{FOOTER}}'
     2842                        ),
     2843                        'replacements' => array(
     2844                                '{{USERNAME}}'  => $current_user->user_login,
     2845                                '{{ADMIN_URL}}' => esc_url_raw( admin_url( 'profile.php?newuseremail=' . $hash ) ),
     2846                                '{{EMAIL}}'     => $_POST['email'],
     2847                        ),
    28512848                );
    28522849
    2853                 /**
    2854                  * Filters the text of the email sent when a change of user email address is attempted.
    2855                  *
    2856                  * The following strings have a special meaning and will get replaced dynamically:
    2857                  * ###USERNAME###  The current user's username.
    2858                  * ###ADMIN_URL### The link to click on to confirm the email change.
    2859                  * ###EMAIL###     The new email.
    2860                  * ###SITENAME###  The name of the site.
    2861                  * ###SITEURL###   The URL to the site.
    2862                  *
    2863                  * @since MU (3.0.0)
    2864                  * @since 4.9.0 This filter is no longer Multisite specific.
    2865                  *
    2866                  * @param string $email_text     Text in the email.
    2867                  * @param array  $new_user_email {
    2868                  *     Data relating to the new user email address.
    2869                  *
    2870                  *     @type string $hash     The secure hash used in the confirmation link URL.
    2871                  *     @type string $newemail The proposed new email address.
    2872                  * }
    2873                  */
    2874                 $content = apply_filters( 'new_user_email_content', $email_text, $new_user_email );
     2850                $wp_mailer = WP_Mailer::getInstance();
     2851                $wp_mailer->send( $wp_mail );
    28752852
    2876                 $content = str_replace( '###USERNAME###', $current_user->user_login, $content );
    2877                 $content = str_replace( '###ADMIN_URL###', esc_url( admin_url( 'profile.php?newuseremail=' . $hash ) ), $content );
    2878                 $content = str_replace( '###EMAIL###', $_POST['email'], $content );
    2879                 $content = str_replace( '###SITENAME###', $sitename, $content );
    2880                 $content = str_replace( '###SITEURL###', home_url(), $content );
    2881 
    2882                 /* translators: New email address notification email subject. %s: Site title. */
    2883                 wp_mail( $_POST['email'], sprintf( __( '[%s] Email Change Request' ), $sitename ), $content );
    2884 
    28852853                $_POST['email'] = $current_user->user_email;
    28862854        }
    28872855}
     
    31883156                return;
    31893157        }
    31903158
     3159        $manage_url = '';
    31913160        if ( 'export_personal_data' === $request->action_name ) {
    31923161                $manage_url = admin_url( 'export-personal-data.php' );
    31933162        } elseif ( 'remove_personal_data' === $request->action_name ) {
     
    31963165        $action_description = wp_user_request_action_description( $request->action_name );
    31973166
    31983167        /**
    3199          * Filters the recipient of the data request confirmation notification.
     3168         * Filters removed
    32003169         *
    3201          * In a Multisite environment, this will default to the email address of the
    3202          * network admin because, by default, single site admins do not have the
    3203          * capabilities required to process requests. Some networks may wish to
    3204          * delegate those capabilities to a single-site admin, or a dedicated person
    3205          * responsible for managing privacy requests.
     3170         * $admin_email = apply_filters( 'user_request_confirmed_email_to', get_site_option( 'admin_email' ), $request );
     3171         * $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3172         * $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3173         * $headers = apply_filters( 'user_request_confirmed_email_headers', $headers, $subject, $content, $request_id, $email_data );
    32063174         *
    3207          * @since 4.9.6
     3175         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    32083176         *
    3209          * @param string          $admin_email The email address of the notification recipient.
    3210          * @param WP_User_Request $request     The request that is initiating the notification.
     3177         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     3178         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     3179         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
     3180         *
    32113181         */
    3212         $admin_email = apply_filters( 'user_request_confirmed_email_to', get_site_option( 'admin_email' ), $request );
    32133182
    3214         $email_data = array(
    3215                 'request'     => $request,
    3216                 'user_email'  => $request->email,
    3217                 'description' => $action_description,
    3218                 'manage_url'  => $manage_url,
    3219                 'sitename'    => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
    3220                 'siteurl'     => home_url(),
    3221                 'admin_email' => $admin_email,
    3222         );
     3183        $wp_mail = array(
     3184                'id' => 'user_request_confirmed_email',
     3185                'group' => 'privacy',
    32233186
    3224         /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */
    3225         $email_text = __(
    3226                 'Howdy,
     3187                'to' => get_site_option( 'admin_email' ),
     3188                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3189                'subject' => __( '[{{SITENAME}}] Action Confirmed: {{ACTION_NAME}}' ),
     3190                'message' => __(
     3191'{{HEADER}}
    32273192
    3228 A user data privacy request has been confirmed on ###SITENAME###:
     3193A user data privacy request has been confirmed on {{SITENAME}}:
    32293194
    3230 User: ###USER_EMAIL###
    3231 Request: ###DESCRIPTION###
     3195User: {{EMAIL}}
     3196Request: {{ACTION_NAME}}
    32323197
    32333198You can view and manage these data privacy requests here:
    32343199
    3235 ###MANAGE_URL###
     3200{{ADMIN_URL}}
    32363201
    3237 Regards,
    3238 All at ###SITENAME###
    3239 ###SITEURL###'
     3202{{FOOTER}}'
     3203                ),
     3204                'replacements' => array(
     3205                        '{{EMAIL}}'     => $request->email,
     3206                        '{{ACTION_NAME}}' => wp_user_request_action_description( $request->action_name ),
     3207                        '{{ADMIN_URL}}'   => esc_url_raw( $manage_url ),
     3208                ),
    32403209        );
    32413210
    3242         /**
    3243          * Filters the body of the user request confirmation email.
    3244          *
    3245          * The email is sent to an administrator when an user request is confirmed.
    3246          * The following strings have a special meaning and will get replaced dynamically:
    3247          *
    3248          * ###SITENAME###    The name of the site.
    3249          * ###USER_EMAIL###  The user email for the request.
    3250          * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
    3251          * ###MANAGE_URL###  The URL to manage requests.
    3252          * ###SITEURL###     The URL to the site.
    3253          *
    3254          * @since 4.9.6
    3255          *
    3256          * @param string $email_text Text in the email.
    3257          * @param array  $email_data {
    3258          *     Data relating to the account action email.
    3259          *
    3260          *     @type WP_User_Request $request     User request object.
    3261          *     @type string          $user_email  The email address confirming a request
    3262          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3263          *     @type string          $manage_url  The link to click manage privacy requests of this type.
    3264          *     @type string          $sitename    The site name sending the mail.
    3265          *     @type string          $siteurl     The site URL sending the mail.
    3266          *     @type string          $admin_email The administrator email receiving the mail.
    3267          * }
    3268          */
    3269         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3211        $wp_mailer = WP_Mailer::getInstance();
     3212        $email_sent = $wp_mailer->send( $wp_mail );
    32703213
    3271         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3272         $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
    3273         $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    3274         $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
    3275         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    3276 
    3277         $subject = sprintf(
    3278                 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
    3279                 __( '[%1$s] Action Confirmed: %2$s' ),
    3280                 $email_data['sitename'],
    3281                 $action_description
    3282         );
    3283 
    3284         /**
    3285          * Filters the subject of the user request confirmation email.
    3286          *
    3287          * @since 4.9.8
    3288          *
    3289          * @param string $subject    The email subject.
    3290          * @param string $sitename   The name of the site.
    3291          * @param array  $email_data {
    3292          *     Data relating to the account action email.
    3293          *
    3294          *     @type WP_User_Request $request     User request object.
    3295          *     @type string          $user_email  The email address confirming a request
    3296          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3297          *     @type string          $manage_url  The link to click manage privacy requests of this type.
    3298          *     @type string          $sitename    The site name sending the mail.
    3299          *     @type string          $siteurl     The site URL sending the mail.
    3300          *     @type string          $admin_email The administrator email receiving the mail.
    3301          * }
    3302          */
    3303         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
    3304 
    3305         $headers = '';
    3306 
    3307         /**
    3308          * Filters the headers of the user request confirmation email.
    3309          *
    3310          * @since 5.4.0
    3311          *
    3312          * @param string|array $headers    The email headers.
    3313          * @param string       $subject    The email subject.
    3314          * @param string       $content    The email content.
    3315          * @param int          $request_id The request ID.
    3316          * @param array        $email_data {
    3317          *     Data relating to the account action email.
    3318          *
    3319          *     @type WP_User_Request $request     User request object.
    3320          *     @type string          $user_email  The email address confirming a request
    3321          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3322          *     @type string          $manage_url  The link to click manage privacy requests of this type.
    3323          *     @type string          $sitename    The site name sending the mail.
    3324          *     @type string          $siteurl     The site URL sending the mail.
    3325          *     @type string          $admin_email The administrator email receiving the mail.
    3326          * }
    3327          */
    3328         $headers = apply_filters( 'user_request_confirmed_email_headers', $headers, $subject, $content, $request_id, $email_data );
    3329 
    3330         $email_sent = wp_mail( $email_data['admin_email'], $subject, $content, $headers );
    3331 
    33323214        if ( $email_sent ) {
    33333215                update_post_meta( $request_id, '_wp_admin_notified', true );
    33343216        }
     
    33563238                return;
    33573239        }
    33583240
     3241        $privacy_policy_url = get_privacy_policy_url();
     3242
    33593243        // Localize message content for user; fallback to site default for visitors.
    33603244        if ( ! empty( $request->user_id ) ) {
    33613245                $locale = get_user_locale( $request->user_id );
     
    33663250        $switched_locale = switch_to_locale( $locale );
    33673251
    33683252        /**
    3369          * Filters the recipient of the data erasure fulfillment notification.
     3253         * Filters removed
    33703254         *
    3371          * @since 4.9.6
     3255         * $user_email = apply_filters( 'user_erasure_fulfillment_email_to', $request->email, $request );
     3256         * $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3257         * $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3258         * $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
    33723259         *
    3373          * @param string          $user_email The email address of the notification recipient.
    3374          * @param WP_User_Request $request    The request that is initiating the notification.
    3375          */
    3376         $user_email = apply_filters( 'user_erasure_fulfillment_email_to', $request->email, $request );
    3377 
    3378         $email_data = array(
    3379                 'request'            => $request,
    3380                 'message_recipient'  => $user_email,
    3381                 'privacy_policy_url' => get_privacy_policy_url(),
    3382                 'sitename'           => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
    3383                 'siteurl'            => home_url(),
    3384         );
    3385 
    3386         $subject = sprintf(
    3387                 /* translators: Erasure request fulfilled notification email subject. %s: Site title. */
    3388                 __( '[%s] Erasure Request Fulfilled' ),
    3389                 $email_data['sitename']
    3390         );
    3391 
    3392         /**
    3393          * Filters the subject of the email sent when an erasure request is completed.
     3260         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    33943261         *
    3395          * @since 4.9.8
     3262         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     3263         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     3264         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    33963265         *
    3397          * @param string $subject    The email subject.
    3398          * @param string $sitename   The name of the site.
    3399          * @param array  $email_data {
    3400          *     Data relating to the account action email.
    3401          *
    3402          *     @type WP_User_Request $request            User request object.
    3403          *     @type string          $message_recipient  The address that the email will be sent to. Defaults
    3404          *                                               to the value of `$request->email`, but can be changed
    3405          *                                               by the `user_erasure_fulfillment_email_to` filter.
    3406          *     @type string          $privacy_policy_url Privacy policy URL.
    3407          *     @type string          $sitename           The site name sending the mail.
    3408          *     @type string          $siteurl            The site URL sending the mail.
    3409          * }
    34103266         */
    3411         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
    34123267
    3413         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3414                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3415                 $email_text = __(
    3416                         'Howdy,
     3268        $notify_message = array();
     3269        /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3270        $notify_message[] = __(
     3271'{{HEADER}}
    34173272
    3418 Your request to erase your personal data on ###SITENAME### has been completed.
     3273Your request to erase your personal data on {{SITENAME}} has been completed.
    34193274
    3420 If you have any follow-up questions or concerns, please contact the site administrator.
     3275If you have any follow-up questions or concerns, please contact the site administrator.'
     3276);
    34213277
    3422 Regards,
    3423 All at ###SITENAME###
    3424 ###SITEURL###'
    3425                 );
    3426         } else {
    3427                 /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3428                 $email_text = __(
    3429                         'Howdy,
    3430 
    3431 Your request to erase your personal data on ###SITENAME### has been completed.
    3432 
    3433 If you have any follow-up questions or concerns, please contact the site administrator.
    3434 
    3435 For more information, you can also read our privacy policy: ###PRIVACY_POLICY_URL###
    3436 
    3437 Regards,
    3438 All at ###SITENAME###
    3439 ###SITEURL###'
    3440                 );
     3278        if ( !empty( $privacy_policy_url ) ) {
     3279                $notify_message[] = '';
     3280                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3281                $notify_message[] = __( 'For more information, you can also read our privacy policy: {{PRIVACY_POLICY_URL}}' );
    34413282        }
    34423283
    3443         /**
    3444          * Filters the body of the data erasure fulfillment notification.
    3445          *
    3446          * The email is sent to a user when a their data erasure request is fulfilled
    3447          * by an administrator.
    3448          *
    3449          * The following strings have a special meaning and will get replaced dynamically:
    3450          *
    3451          * ###SITENAME###           The name of the site.
    3452          * ###PRIVACY_POLICY_URL### Privacy policy page URL.
    3453          * ###SITEURL###            The URL to the site.
    3454          *
    3455          * @since 4.9.6
    3456          *
    3457          * @param string $email_text Text in the email.
    3458          * @param array  $email_data {
    3459          *     Data relating to the account action email.
    3460          *
    3461          *     @type WP_User_Request $request            User request object.
    3462          *     @type string          $message_recipient  The address that the email will be sent to. Defaults
    3463          *                                               to the value of `$request->email`, but can be changed
    3464          *                                               by the `user_erasure_fulfillment_email_to` filter.
    3465          *     @type string          $privacy_policy_url Privacy policy URL.
    3466          *     @type string          $sitename           The site name sending the mail.
    3467          *     @type string          $siteurl            The site URL sending the mail.
    3468          * }
    3469          */
    3470         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3284        $notify_message[] = '';
     3285        $notify_message[] = '{{FOOTER}}';
    34713286
    3472         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3473         $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    3474         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3287        $wp_mail = array(
     3288                'id' => 'user_erasure_complete_email',
     3289                'group' => 'privacy',
    34753290
    3476         $headers = '';
     3291                'to' => $request->email,
     3292                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3293                'subject' => __( '[{{SITENAME}}] Erasure Request Fulfilled' ),
     3294                'message' => implode( "\r\n", $notify_message ),
     3295                'replacements' => array(
     3296                        '{{PRIVACY_POLICY_URL}}'   => esc_url_raw( $privacy_policy_url )
     3297                ),
     3298        );
    34773299
    3478         /**
    3479          * Filters the headers of the data erasure fulfillment notification.
    3480          *
    3481          * @since 5.4.0
    3482          *
    3483          * @param string|array $headers    The email headers.
    3484          * @param string       $subject    The email subject.
    3485          * @param string       $content    The email content.
    3486          * @param int          $request_id The request ID.
    3487          * @param array        $email_data {
    3488          *     Data relating to the account action email.
    3489          *
    3490          *     @type WP_User_Request $request            User request object.
    3491          *     @type string          $message_recipient  The address that the email will be sent to. Defaults
    3492          *                                               to the value of `$request->email`, but can be changed
    3493          *                                               by the `user_erasure_fulfillment_email_to` filter.
    3494          *     @type string          $privacy_policy_url Privacy policy URL.
    3495          *     @type string          $sitename           The site name sending the mail.
    3496          *     @type string          $siteurl            The site URL sending the mail.
    3497          * }
    3498          */
    3499         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3300        $wp_mailer = WP_Mailer::getInstance();
     3301        $email_sent = $wp_mailer->send( $wp_mail );
    35003302
    3501         $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    3502 
    35033303        if ( $switched_locale ) {
    35043304                restore_previous_locale();
    35053305        }
     
    36613461                return new WP_Error( 'invalid_request', __( 'Invalid user request.' ) );
    36623462        }
    36633463
    3664         // Localize message content for user; fallback to site default for visitors.
    3665         if ( ! empty( $request->user_id ) ) {
    3666                 $locale = get_user_locale( $request->user_id );
    3667         } else {
    3668                 $locale = get_locale();
    3669         }
    3670 
    3671         $switched_locale = switch_to_locale( $locale );
    3672 
    3673         $email_data = array(
    3674                 'request'     => $request,
    3675                 'email'       => $request->email,
    3676                 'description' => wp_user_request_action_description( $request->action_name ),
    3677                 'confirm_url' => add_query_arg(
     3464        $confirm_url = add_query_arg(
    36783465                        array(
    36793466                                'action'      => 'confirmaction',
    36803467                                'request_id'  => $request_id,
     
    36813468                                'confirm_key' => wp_generate_user_request_key( $request_id ),
    36823469                        ),
    36833470                        wp_login_url()
    3684                 ),
    3685                 'sitename'    => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
    3686                 'siteurl'     => home_url(),
    36873471        );
    36883472
    3689         /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    3690         $email_text = __(
    3691                 'Howdy,
     3473        $is_privacy = ( in_array( $request->action_name, _wp_privacy_action_request_types(), true ) );
    36923474
    3693 A request has been made to perform the following action on your account:
     3475        // Localize message content for user; fallback to site default for visitors.
     3476        if ( ! empty( $request->user_id ) ) {
     3477                $locale = get_user_locale( $request->user_id );
     3478        } else {
     3479                $locale = get_locale();
     3480        }
    36943481
    3695      ###DESCRIPTION###
    3696 
    3697 To confirm this, please click on the following link:
    3698 ###CONFIRM_URL###
    3699 
    3700 You can safely ignore and delete this email if you do not want to
    3701 take this action.
    3702 
    3703 Regards,
    3704 All at ###SITENAME###
    3705 ###SITEURL###'
    3706         );
    3707 
     3482        $switched_locale = switch_to_locale( $locale );
     3483       
    37083484        /**
    3709          * Filters the text of the email sent when an account action is attempted.
     3485         * Filters removed
    37103486         *
    3711          * The following strings have a special meaning and will get replaced dynamically:
     3487         * $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     3488         * $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     3489         * $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
    37123490         *
    3713          * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
    3714          * ###CONFIRM_URL### The link to click on to confirm the account action.
    3715          * ###SITENAME###    The name of the site.
    3716          * ###SITEURL###     The URL to the site.
     3491         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    37173492         *
    3718          * @since 4.9.6
     3493         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     3494         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     3495         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    37193496         *
    3720          * @param string $email_text Text in the email.
    3721          * @param array  $email_data {
    3722          *     Data relating to the account action email.
    3723          *
    3724          *     @type WP_User_Request $request     User request object.
    3725          *     @type string          $email       The email address this is being sent to.
    3726          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3727          *     @type string          $confirm_url The link to click on to confirm the account action.
    3728          *     @type string          $sitename    The site name sending the mail.
    3729          *     @type string          $siteurl     The site URL sending the mail.
    3730          * }
    37313497         */
    3732         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
    37333498
    3734         $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    3735         $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
    3736         $content = str_replace( '###EMAIL###', $email_data['email'], $content );
    3737         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3738         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3499        $wp_mail = array(
     3500                'id' => 'user_request_action_email',
     3501                'group' => ( $is_privacy ) ? 'privacy' : 'blog',
    37393502
    3740         /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
    3741         $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     3503                'to' => $request->email,
     3504                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3505                'subject' => __( '[{{SITENAME}}] Confirm Action: {{ACTION_NAME}}' ),
     3506                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     3507                'message' => __(
     3508'{{HEADER}}
    37423509
    3743         /**
    3744          * Filters the subject of the email sent when an account action is attempted.
    3745          *
    3746          * @since 4.9.6
    3747          *
    3748          * @param string $subject    The email subject.
    3749          * @param string $sitename   The name of the site.
    3750          * @param array  $email_data {
    3751          *     Data relating to the account action email.
    3752          *
    3753          *     @type WP_User_Request $request     User request object.
    3754          *     @type string          $email       The email address this is being sent to.
    3755          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3756          *     @type string          $confirm_url The link to click on to confirm the account action.
    3757          *     @type string          $sitename    The site name sending the mail.
    3758          *     @type string          $siteurl     The site URL sending the mail.
    3759          * }
    3760          */
    3761         $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     3510A request has been made to perform the following action on your account:
    37623511
    3763         $headers = '';
     3512     {{ACTION_NAME}}
    37643513
    3765         /**
    3766          * Filters the headers of the email sent when an account action is attempted.
    3767          *
    3768          * @since 5.4.0
    3769          *
    3770          * @param string|array $headers    The email headers.
    3771          * @param string       $subject    The email subject.
    3772          * @param string       $content    The email content.
    3773          * @param int          $request_id The request ID.
    3774          * @param array        $email_data {
    3775          *     Data relating to the account action email.
    3776          *
    3777          *     @type WP_User_Request $request     User request object.
    3778          *     @type string          $email       The email address this is being sent to.
    3779          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3780          *     @type string          $confirm_url The link to click on to confirm the account action.
    3781          *     @type string          $sitename    The site name sending the mail.
    3782          *     @type string          $siteurl     The site URL sending the mail.
    3783          * }
    3784          */
    3785         $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3514To confirm this, please click on the following link:
     3515{{LOGINLINK}}
    37863516
    3787         $email_sent = wp_mail( $email_data['email'], $subject, $content, $headers );
     3517You can safely ignore and delete this email if you do not want to
     3518take this action.
    37883519
     3520{{FOOTER}}'
     3521                ),
     3522                'replacements' => array(
     3523                        '{{ACTION_NAME}}' => wp_user_request_action_description( $request->action_name ),
     3524                        '{{LOGINLINK}}'   => esc_url_raw( $confirm_url ),
     3525                ),
     3526        );
     3527
     3528        $wp_mailer = WP_Mailer::getInstance();
     3529        $email_sent = $wp_mailer->send( $wp_mail );
     3530
    37893531        if ( $switched_locale ) {
    37903532                restore_previous_locale();
    37913533        }
  • wp-login.php

     
    415415                $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    416416        }
    417417
    418         $message = __( 'Someone has requested a password reset for the following account:' ) . "\r\n\r\n";
    419         /* translators: %s: Site name. */
    420         $message .= sprintf( __( 'Site Name: %s' ), $site_name ) . "\r\n\r\n";
    421         /* translators: %s: User login. */
    422         $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n";
    423         $message .= __( 'If this was a mistake, just ignore this email and nothing will happen.' ) . "\r\n\r\n";
    424         $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n";
    425         $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "\r\n";
    426 
    427         /* translators: Password reset notification email subject. %s: Site title. */
    428         $title = sprintf( __( '[%s] Password Reset' ), $site_name );
    429 
    430418        /**
    431          * Filters the subject of the password reset email.
     419         * Filters removed
    432420         *
    433          * @since 2.8.0
    434          * @since 4.4.0 Added the `$user_login` and `$user_data` parameters.
     421         * $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
     422         * $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
    435423         *
    436          * @param string  $title      Default email title.
    437          * @param string  $user_login The username for the user.
    438          * @param WP_User $user_data  WP_User object.
    439          */
    440         $title = apply_filters( 'retrieve_password_title', $title, $user_login, $user_data );
    441 
    442         /**
    443          * Filters the message body of the password reset mail.
     424         * all mails components are filterable using wp-includes/class-wp-mailer.php filters
    444425         *
    445          * If the filtered message is empty, the password reset email will not be sent.
     426         *              apply_filters( 'wp_mailer',                        $mail, $caller_info );
     427         *              apply_filters( "wp_mailer_group_{$mail['group']}", $mail, $caller_info );
     428         *              apply_filters( "wp_mailer_{$mail['id']}",          $mail, $caller_info );
    446429         *
    447          * @since 2.8.0
    448          * @since 4.1.0 Added `$user_login` and `$user_data` parameters.
    449          *
    450          * @param string  $message    Default mail message.
    451          * @param string  $key        The activation key.
    452          * @param string  $user_login The username for the user.
    453          * @param WP_User $user_data  WP_User object.
    454430         */
    455         $message = apply_filters( 'retrieve_password_message', $message, $key, $user_login, $user_data );
    456431
    457         if ( $message && ! wp_mail( $user_email, wp_specialchars_decode( $title ), $message ) ) {
     432        $wp_mail = array(
     433                'id' => 'retrieve_password',
     434                'group' => 'blog',
     435
     436                'to' => $user_email,
     437                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     438                'subject' => __( '[{{SITENAME}}] Password Reset' ),
     439                /* translators: Do not translate any string between double curled brackets {{STRING}} : those are "mustache" placeholders. */
     440                'message' => __(
     441'{{HEADER}}
     442
     443Someone has requested a password reset for the following account:
     444
     445Site Name: {{SITENAME}}
     446
     447Username: {{USERNAME}}
     448
     449If this was a mistake, just ignore this email and nothing will happen.
     450
     451To reset your password, visit the following address:
     452
     453{{RESETLINK}}
     454
     455{{FOOTER}}'
     456                ),
     457                'replacements' => array(
     458                        '{{SITENAME}}'  => $site_name,
     459                        '{{USERNAME}}'  => $user_login,
     460                        '{{RESETLINK}}' => esc_url_raw( network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) )
     461                ),
     462        );
     463
     464        $wp_mailer = WP_Mailer::getInstance();
     465        if ( ! $wp_mailer->send( $wp_mail ) ) {
    458466                $errors->add(
    459467                        'retrieve_password_email_failure',
    460468                        sprintf(
  • wp-settings.php

     
    281281require ABSPATH . WPINC . '/blocks/shortcode.php';
    282282require ABSPATH . WPINC . '/blocks/social-link.php';
    283283require ABSPATH . WPINC . '/blocks/tag-cloud.php';
     284require ABSPATH . WPINC . '/class-wp-mailer.php';
    284285
     286
    285287$GLOBALS['wp_embed'] = new WP_Embed();
    286288
    287289// Load multisite-specific files.