WordPress.org

Make WordPress Core

Ticket #42133: 42133.patch

File 42133.patch, 3.2 KB (added by Dharm1025, 10 months ago)

All data now passed through a filter.

  • includes/upgrade.php

     
    375375 */
    376376function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
    377377        $user = new WP_User( $user_id );
    378         $email = $user->user_email;
    379378        $name = $user->user_login;
    380379        $login_url = wp_login_url();
    381         /* translators: New site notification email. 1: New site URL, 2: User login, 3: User password or password reset link, 4: Login URL */
    382         $message = sprintf( __( "Your new WordPress site has been successfully set up at:
     380        /* translators: New site notification email. Do not translate SITEURL, USERNAME, PASSWORD, LOGINURL: those are placeholders. */
     381        $new_blog_text =__( "Your new WordPress site has been successfully set up at:
    383382
    384 %1\$s
     383###SITEURL###
    385384
    386385You can log in to the administrator account with the following information:
    387386
    388 Username: %2\$s
    389 Password: %3\$s
    390 Log in here: %4\$s
     387Username: ###USERNAME###
     388Password: ###PASSWORD###
     389Log in here: ###LOGINURL###
    391390
    392391We hope you enjoy your new site. Thanks!
    393392
    394393--The WordPress Team
    395394https://wordpress.org/
    396 "), $blog_url, $name, $password, $login_url );
     395" );
    397396
    398         @wp_mail($email, __('New WordPress Site'), $message);
     397        $new_blog_email = array(
     398                'to'      => $user->user_email,
     399                /* translators: New site notification email subject. */
     400                'subject' => __( 'New WordPress Site' ),
     401                'message' => $new_blog_text,
     402                'headers' => '',
     403        );
     404
     405        /**
     406         * Filters the contents of the email sent when the new blog is create.
     407         *
     408         * @since
     409         *
     410         * @param array $new_blog_email {
     411         *            Used to build wp_mail().
     412         *            @type string $to      The intended recipients. Add emails in a comma separated string.
     413         *            @type string $subject The subject of the email.
     414         *            @type string $message The content of the email.
     415         *                The following strings have a special meaning and will get replaced dynamically:
     416         *                - ###SITEURL###     The URL of the new created site.
     417         *                - ###USERNAME###    The site administrator's username.
     418         *                - ###PASSWORD###    The site administrator's password.
     419         *                - ###LOGINURL###        The Login URL of the site.
     420         *            @type string $headers Headers. Add headers in a newline (\r\n) separated string.
     421         *        }
     422         * @param int    $user_id    User ID.
     423         * @param string $blog_title Site title.
     424         * @param string $blog_url   Site url.
     425         * @param string $password   User's Password.
     426         *
     427         */
     428        $new_blog_email = apply_filters( 'new_blog_email', $new_blog_email, $blog_title, $blog_url, $user_id, $password );
     429
     430        $new_blog_email['message'] = str_replace( '###SITEURL###', $blog_url, $new_blog_email['message'] );
     431        $new_blog_email['message'] = str_replace( '###USERNAME###', $name, $new_blog_email['message'] );
     432        $new_blog_email['message'] = str_replace( '###PASSWORD###', $password, $new_blog_email['message'] );
     433        $new_blog_email['message'] = str_replace( '###LOGINURL###', $login_url, $new_blog_email['message'] );
     434
     435        wp_mail( $new_blog_email['to'], $new_blog_email['subject'], $new_blog_email['message'], $new_blog_email['headers'] );
    399436}
    400437endif;
    401438