From eaf325e386f2784c5da89bf206693e84c8b1a25f Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 25 Sep 2020 22:33:08 +0000 Subject: [PATCH] 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 Built from https://develop.svn.wordpress.org/trunk@49048 git-svn-id: http://core.svn.wordpress.org/trunk@48810 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 46 ++++++++++++++++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index e0170f2705..bb6ea18bc5 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -586,17 +586,18 @@ function wp_install_maybe_enable_pretty_permalinks() { if ( ! function_exists( 'wp_new_blog_notification' ) ) : /** - * Notifies the site admin that the setup is complete. + * Notifies the site admin that the installation of WordPress is complete. * - * Sends an email with wp_mail to the new administrator that the site setup is complete, + * Sends an email to the new administrator that the installation is complete * and provides them with a record of their login credentials. * * @since 2.1.0 * * @param string $blog_title Site title. - * @param string $blog_url Site url. - * @param int $user_id User ID. - * @param string $password User's Password. + * @param string $blog_url Site URL. + * @param int $user_id Administrator's user ID. + * @param string $password Administrator's password. Note that a placeholder message is + * usually passed instead of the actual password. */ function wp_new_blog_notification( $blog_title, $blog_url, $user_id, $password ) { $user = new WP_User( $user_id ); @@ -629,7 +630,40 @@ https://wordpress.org/ $login_url ); - wp_mail( $email, __( 'New WordPress Site' ), $message ); + $installed_email = array( + 'to' => $email, + 'subject' => __( 'New WordPress Site' ), + 'message' => $message, + 'headers' => '', + ); + + /** + * Filters the contents of the email sent to the site administrator when WordPress is installed. + * + * @since 5.6.0 + * + * @param array $installed_email { + * Used to build wp_mail(). + * + * @type string $to The email address of the recipient. + * @type string $subject The subject of the email. + * @type string $message The content of the email. + * @type string $headers Headers. + * } + * @param WP_User $user The site administrator user object. + * @param string $blog_title The site title. + * @param string $blog_url The site URL. + * @param string $password The site administrator's password. Note that a placeholder message + * is usually passed instead of the user's actual password. + */ + $installed_email = apply_filters( 'wp_installed_email', $installed_email, $user, $blog_title, $blog_url, $password ); + + wp_mail( + $installed_email['to'], + $installed_email['subject'], + $installed_email['message'], + $installed_email['headers'] + ); } endif; diff --git a/wp-includes/version.php b/wp-includes/version.php index f53ad8643f..60ebe6a26c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49047'; +$wp_version = '5.6-alpha-49048'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.