Make WordPress Core

Changeset 49048


Ignore:
Timestamp:
09/25/2020 10:31:27 PM (16 months ago)
Author:
johnbillion
Message:

Upgrade/Install: Introduce the wp_installed_email filter for filtering the contents of the email sent when WordPress is installed, without needing to override the wp_new_blog_notification() pluggable function.

Props Dharm1025, nikolam, johnbillion

Fixes #42133

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/upgrade.php

    r48868 r49048  
    587587if ( ! function_exists( 'wp_new_blog_notification' ) ) :
    588588    /**
    589      * Notifies the site admin that the setup is complete.
     589     * Notifies the site admin that the installation of WordPress is complete.
    590590     *
    591      * Sends an email with wp_mail to the new administrator that the site setup is complete,
     591     * Sends an email to the new administrator that the installation is complete
    592592     * and provides them with a record of their login credentials.
    593593     *
     
    595595     *
    596596     * @param string $blog_title Site title.
    597      * @param string $blog_url   Site url.
    598      * @param int    $user_id    User ID.
    599      * @param string $password   User's Password.
     597     * @param string $blog_url   Site URL.
     598     * @param int    $user_id    Administrator's user ID.
     599     * @param string $password   Administrator's password. Note that a placeholder message is
     600     *                           usually passed instead of the actual password.
    600601     */
    601602    function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) {
     
    630631        );
    631632
    632         wp_mail( $email, __( 'New WordPress Site' ), $message );
     633        $installed_email = array(
     634            'to'      => $email,
     635            'subject' => __( 'New WordPress Site' ),
     636            'message' => $message,
     637            'headers' => '',
     638        );
     639
     640        /**
     641         * Filters the contents of the email sent to the site administrator when WordPress is installed.
     642         *
     643         * @since 5.6.0
     644         *
     645         * @param array $installed_email {
     646         *     Used to build wp_mail().
     647         *
     648         *     @type string $to      The email address of the recipient.
     649         *     @type string $subject The subject of the email.
     650         *     @type string $message The content of the email.
     651         *     @type string $headers Headers.
     652         * }
     653         * @param WP_User $user          The site administrator user object.
     654         * @param string  $blog_title    The site title.
     655         * @param string  $blog_url      The site URL.
     656         * @param string  $password      The site administrator's password. Note that a placeholder message
     657         *                               is usually passed instead of the user's actual password.
     658         */
     659        $installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password );
     660
     661        wp_mail(
     662            $installed_email['to'],
     663            $installed_email['subject'],
     664            $installed_email['message'],
     665            $installed_email['headers']
     666        );
    633667    }
    634668endif;
Note: See TracChangeset for help on using the changeset viewer.