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
This commit is contained in:
John Blackbourn 2020-09-25 22:33:08 +00:00
parent fe9e57c1c3
commit eaf325e386
2 changed files with 41 additions and 7 deletions

View File

@ -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;

View File

@ -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.