Skip to content

Commit 775e86c

Browse files
committed
Fix WPCS violations and coding standards in core email triggers
1 parent 40a3fce commit 775e86c

5 files changed

Lines changed: 44 additions & 36 deletions

File tree

src/wp-admin/includes/privacy-tools.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,12 @@ function wp_privacy_send_personal_data_export_email( $request_id ) {
623623
$request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
624624

625625
$email_data = array(
626-
'request' => $request,
627-
'expiration' => $expiration,
628-
'expiration_date' => $expiration_date,
629-
'message_recipient' => $request_email,
630-
'export_file_url' => $export_file_url,
631-
'sitename' => $site_name,
632-
'siteurl' => $site_url,
626+
'request' => $request,
627+
'expiration' => $expiration,
628+
'expiration_date' => $expiration_date,
629+
'export_file_url' => $export_file_url,
630+
'sitename' => $site_name,
631+
'siteurl' => $site_url,
633632
);
634633

635634
$email_data = array(

src/wp-includes/class-wp-mailer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ public static function send( $email_id, $args = array(), $data = array() ) {
8888
$message = apply_filters( "wp_mailer_{$group}_message", $message, $email_id, $data );
8989
$message = apply_filters( "wp_mailer_{$email_id}_message", $message, $email_id, $data );
9090

91-
$to = isset( $args['to'] ) ? $args['to'] : '';
92-
$headers = isset( $args['headers'] ) ? $args['headers'] : '';
93-
$attachments = isset( $args['attachments'] ) ? $args['attachments'] : array();
91+
$to = isset( $args['to'] ) ? $args[ 'to' ] : '';
92+
$headers = isset( $args['headers'] ) ? $args[ 'headers' ] : '';
93+
$attachments = isset( $args['attachments'] ) ? $args[ 'attachments' ] : array();
9494

9595
/**
9696
* Filters the email headers before sending.
@@ -169,9 +169,9 @@ public static function get_email( $email_id ) {
169169
public static function render( $template, $data ) {
170170
return preg_replace_callback(
171171
'/{{(.*?)}}/',
172-
function ( $matches ) use ( $data ) {
173-
$key = trim( $matches[1] );
174-
return isset( $data[ $key ] ) ? $data[ $key ] : $matches[0];
172+
function( $matches ) use ( $data ) {
173+
$key = trim( $matches[ 1 ] );
174+
return isset( $data[ $key ] ) ? $data[ $key ] : $matches[ 0 ];
175175
},
176176
$template
177177
);

src/wp-includes/pluggable.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,7 +2333,7 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' )
23332333
/* translators: New user registration notification email subject. %s: Site title. */
23342334
$subject = sprintf( __( '[%s] New User Registration' ), $blogname );
23352335

2336-
$message = WP_Mailer::render( WP_Mailer::get_email( 'new_user_admin' )['body'], $email_data );
2336+
$message = WP_Mailer::render( WP_Mailer::get_email( 'new_user_admin' )[ 'body' ], $email_data );
23372337

23382338
$wp_new_user_notification_email_admin = array(
23392339
'to' => get_option( 'admin_email' ),
@@ -2348,13 +2348,16 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' )
23482348
WP_Mailer::send(
23492349
'new_user_admin',
23502350
array(
2351-
'to' => $wp_new_user_notification_email_admin['to'],
2352-
'headers' => $wp_new_user_notification_email_admin['headers'],
2351+
'to' => $wp_new_user_notification_email_admin[ 'to' ],
2352+
'headers' => $wp_new_user_notification_email_admin[ 'headers' ],
23532353
),
2354-
array_merge( $email_data, array(
2355-
'subject' => $wp_new_user_notification_email_admin['subject'],
2356-
'body' => $wp_new_user_notification_email_admin['message'],
2357-
) )
2354+
array_merge(
2355+
$email_data,
2356+
array(
2357+
'subject' => $wp_new_user_notification_email_admin[ 'subject' ],
2358+
'body' => $wp_new_user_notification_email_admin[ 'message' ],
2359+
)
2360+
)
23582361
);
23592362

23602363
if ( $switched_locale ) {
@@ -2409,7 +2412,7 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' )
24092412
/* translators: Login details notification email subject. %s: Site title. */
24102413
$subject = sprintf( __( '[%s] Login Details' ), $blogname );
24112414

2412-
$message = WP_Mailer::render( WP_Mailer::get_email( 'new_user' )['body'], $email_data );
2415+
$message = WP_Mailer::render( WP_Mailer::get_email( 'new_user' )[ 'body' ], $email_data );
24132416

24142417
$wp_new_user_notification_email = array(
24152418
'to' => $user->user_email,
@@ -2424,13 +2427,16 @@ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' )
24242427
WP_Mailer::send(
24252428
'new_user',
24262429
array(
2427-
'to' => $wp_new_user_notification_email['to'],
2428-
'headers' => $wp_new_user_notification_email['headers'],
2430+
'to' => $wp_new_user_notification_email[ 'to' ],
2431+
'headers' => $wp_new_user_notification_email[ 'headers' ],
24292432
),
2430-
array_merge( $email_data, array(
2431-
'subject' => $wp_new_user_notification_email['subject'],
2432-
'body' => $wp_new_user_notification_email['message'],
2433-
) )
2433+
array_merge(
2434+
$email_data,
2435+
array(
2436+
'subject' => $wp_new_user_notification_email[ 'subject' ],
2437+
'body' => $wp_new_user_notification_email[ 'message' ],
2438+
)
2439+
)
24342440
);
24352441

24362442
if ( $switched_locale ) {

src/wp-includes/user.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3440,14 +3440,17 @@ function retrieve_password( $user_login = '' ) {
34403440
$mail_success = WP_Mailer::send(
34413441
'retrieve_password',
34423442
array(
3443-
'to' => $notification_email['to'],
3444-
'headers' => $notification_email['headers'],
3443+
'to' => $notification_email[ 'to' ],
3444+
'headers' => $notification_email[ 'headers' ],
34453445
),
3446-
array_merge( $email_data, array(
3447-
// Overwrite subject and body if they were filtered.
3448-
'subject' => $notification_email['subject'],
3449-
'body' => $notification_email['message'],
3450-
) )
3446+
array_merge(
3447+
$email_data,
3448+
array(
3449+
// Overwrite subject and body if they were filtered.
3450+
'subject' => $notification_email[ 'subject' ],
3451+
'body' => $notification_email[ 'message' ],
3452+
)
3453+
)
34513454
);
34523455

34533456
if ( ! $mail_success ) {

tests/phpunit/tests/mail/wpMailer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function test_new_user_templates() {
141141
'sitename' => 'Site',
142142
'user_login' => 'bob',
143143
'user_email' => 'bob@example.com',
144-
));
144+
) );
145145

146146
$mailer = tests_retrieve_phpmailer_instance();
147147
$this->assertSame( '[Site] New User', $mailer->Subject );
@@ -158,7 +158,7 @@ public function test_new_user_templates() {
158158
'sitename' => 'Site',
159159
'user_login' => 'bob',
160160
'set_password_url' => 'http://example.com/set-pw',
161-
));
161+
) );
162162

163163
$mailer = tests_retrieve_phpmailer_instance();
164164
$this->assertSame( '[Site] Login Details', $mailer->Subject );

0 commit comments

Comments
 (0)