Skip to content

Commit ccdb078

Browse files
committed
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
1 parent 671d2ca commit ccdb078

4 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/wp-admin/includes/class-wp-automatic-updater.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,9 +1236,15 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_
12361236
$body[] = __( 'https://wordpress.org/support/forums/' );
12371237
$body[] = "\n" . __( 'The WordPress Team' );
12381238

1239+
if ( '' !== get_option( 'blogname' ) ) {
1240+
$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1241+
} else {
1242+
$site_title = parse_url( home_url(), PHP_URL_HOST );
1243+
}
1244+
12391245
$body = implode( "\n", $body );
12401246
$to = get_site_option( 'admin_email' );
1241-
$subject = sprintf( $subject, wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) );
1247+
$subject = sprintf( $subject, $site_title );
12421248
$headers = '';
12431249

12441250
$email = compact( 'to', 'subject', 'body', 'headers' );
@@ -1347,7 +1353,11 @@ protected function send_debug_email() {
13471353
$body[] = '';
13481354
}
13491355

1350-
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1356+
if ( '' !== get_bloginfo( 'name' ) ) {
1357+
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
1358+
} else {
1359+
$site_title = parse_url( home_url(), PHP_URL_HOST );
1360+
}
13511361

13521362
if ( $failures ) {
13531363
$body[] = trim(

src/wp-admin/includes/misc.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,12 +1472,18 @@ function update_option_new_admin_email( $old_value, $value ) {
14721472
$content = str_replace( '###SITENAME###', wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ), $content );
14731473
$content = str_replace( '###SITEURL###', home_url(), $content );
14741474

1475+
if ( '' !== get_option( 'blogname' ) ) {
1476+
$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1477+
} else {
1478+
$site_title = parse_url( home_url(), PHP_URL_HOST );
1479+
}
1480+
14751481
wp_mail(
14761482
$value,
14771483
sprintf(
14781484
/* translators: New admin email address notification email subject. %s: Site title. */
14791485
__( '[%s] New Admin Email Address' ),
1480-
wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
1486+
$site_title
14811487
),
14821488
$content
14831489
);

src/wp-admin/includes/user.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,12 @@ function admin_created_user_email( $text ) {
578578
$roles = get_editable_roles();
579579
$role = $roles[ $_REQUEST['role'] ];
580580

581+
if ( '' !== get_bloginfo( 'name' ) ) {
582+
$site_title = wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES );
583+
} else {
584+
$site_title = parse_url( home_url(), PHP_URL_HOST );
585+
}
586+
581587
return sprintf(
582588
/* translators: 1: Site title, 2: Site URL, 3: User role. */
583589
__(
@@ -590,7 +596,7 @@ function admin_created_user_email( $text ) {
590596
Please click the following link to activate your user account:
591597
%%s'
592598
),
593-
wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ),
599+
$site_title,
594600
home_url(),
595601
wp_specialchars_decode( translate_user_role( $role['name'] ) )
596602
);

src/wp-admin/user-new.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@
112112

113113
$switched_locale = switch_to_locale( get_user_locale( $user_details ) );
114114

115+
if ( '' !== get_option( 'blogname' ) ) {
116+
$site_title = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
117+
} else {
118+
$site_title = parse_url( home_url(), PHP_URL_HOST );
119+
}
120+
115121
/* translators: 1: Site title, 2: Site URL, 3: User role, 4: Activation URL. */
116122
$message = __(
117123
'Hi,
@@ -127,7 +133,7 @@
127133
$new_user_email['subject'] = sprintf(
128134
/* translators: Joining confirmation notification email subject. %s: Site title. */
129135
__( '[%s] Joining Confirmation' ),
130-
wp_specialchars_decode( get_option( 'blogname' ) )
136+
$site_title
131137
);
132138
$new_user_email['message'] = sprintf(
133139
$message,

0 commit comments

Comments
 (0)