From ccdb078d08a84b31ae7ff055deb0e446a883d894 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Mon, 4 Apr 2022 20:19:12 +0000 Subject: [PATCH] Mail: Replace empty site title with domain name in email subjects. This change replaces site title with domain name in email subjects when the `blogname` option is empty. Props Presskopp, kebbet, audrasjb, azouamauriac. Fixes #54760. git-svn-id: https://develop.svn.wordpress.org/trunk@53063 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-automatic-updater.php | 14 ++++++++++++-- src/wp-admin/includes/misc.php | 8 +++++++- src/wp-admin/includes/user.php | 8 +++++++- src/wp-admin/user-new.php | 8 +++++++- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index 7ba6b71b52..a0405fd0a3 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -1236,9 +1236,15 @@ class WP_Automatic_Updater { $body[] = __( 'https://wordpress.org/support/forums/' ); $body[] = "\n" . __( 'The WordPress Team' ); + if ( '' !== get_option( 'blogname' ) ) { + $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + } else { + $site_title = parse_url( home_url(), PHP_URL_HOST ); + } + $body = implode( "\n", $body ); $to = get_site_option( 'admin_email' ); - $subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); + $subject = sprintf( $subject, $site_title ); $headers = ''; $email = compact( 'to', 'subject', 'body', 'headers' ); @@ -1347,7 +1353,11 @@ class WP_Automatic_Updater { $body[] = ''; } - $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); + if ( '' !== get_bloginfo( 'name' ) ) { + $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); + } else { + $site_title = parse_url( home_url(), PHP_URL_HOST ); + } if ( $failures ) { $body[] = trim( diff --git a/src/wp-admin/includes/misc.php b/src/wp-admin/includes/misc.php index aeeccc9b6f..3b4b6f3e47 100644 --- a/src/wp-admin/includes/misc.php +++ b/src/wp-admin/includes/misc.php @@ -1472,12 +1472,18 @@ All at ###SITENAME### $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content ); $content = str_replace( '###SITEURL###', home_url(), $content ); + if ( '' !== get_option( 'blogname' ) ) { + $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + } else { + $site_title = parse_url( home_url(), PHP_URL_HOST ); + } + wp_mail( $value, sprintf( /* translators: New admin email address notification email subject. %s: Site title. */ __( '[%s] New Admin Email Address' ), - wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) + $site_title ), $content ); diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index 6563859ef7..64b91fce19 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -578,6 +578,12 @@ function admin_created_user_email( $text ) { $roles = get_editable_roles(); $role = $roles[ $_REQUEST['role'] ]; + if ( '' !== get_bloginfo( 'name' ) ) { + $site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); + } else { + $site_title = parse_url( home_url(), PHP_URL_HOST ); + } + return sprintf( /* translators: 1: Site title, 2: Site URL, 3: User role. */ __( @@ -590,7 +596,7 @@ this email. This invitation will expire in a few days. Please click the following link to activate your user account: %%s' ), - wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), + $site_title, home_url(), wp_specialchars_decode( translate_user_role( $role['name'] ) ) ); diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php index 220e0c53eb..4bc2d133cd 100644 --- a/src/wp-admin/user-new.php +++ b/src/wp-admin/user-new.php @@ -112,6 +112,12 @@ if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) { $switched_locale = switch_to_locale( get_user_locale( $user_details ) ); + if ( '' !== get_option( 'blogname' ) ) { + $site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + } else { + $site_title = parse_url( home_url(), PHP_URL_HOST ); + } + /* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */ $message = __( 'Hi, @@ -127,7 +133,7 @@ Please click the following link to confirm the invite: $new_user_email['subject'] = sprintf( /* translators: Joining confirmation notification email subject. %s: Site title. */ __( '[%s] Joining Confirmation' ), - wp_specialchars_decode( get_option( 'blogname' ) ) + $site_title ); $new_user_email['message'] = sprintf( $message,