Skip to content

Commit 5156fed

Browse files
committed
Fix high-priority WPCS violations: use tabs for indentation and correct bracket spacing
1 parent 775e86c commit 5156fed

5 files changed

Lines changed: 61 additions & 54 deletions

File tree

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,6 @@ function wp_privacy_send_personal_data_export_email( $request_id ) {
631631
'siteurl' => $site_url,
632632
);
633633

634-
$email_data = array(
635-
'request' => $request,
636-
'expiration' => $expiration,
637-
'expiration_date' => $expiration_date,
638-
'export_file_url' => $export_file_url,
639-
'sitename' => $site_name,
640-
'siteurl' => $site_url,
641-
);
642-
643634
WP_Mailer::register_email(
644635
'privacy_export',
645636
'privacy',

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function send( $email_id, $args = array(), $data = array() ) {
4747
return false;
4848
}
4949

50-
$group = $email['group'];
50+
$group = $email[ 'group' ];
5151

5252
/**
5353
* Filters the data used for email template rendering.
@@ -61,8 +61,8 @@ public static function send( $email_id, $args = array(), $data = array() ) {
6161
$data = apply_filters( "wp_mailer_{$group}_data", $data, $email_id, $group );
6262
$data = apply_filters( "wp_mailer_{$email_id}_data", $data, $email_id, $group );
6363

64-
$subject = self::render( $email['subject'], $data );
65-
$message = self::render( $email['body'], $data );
64+
$subject = self::render( $email[ 'subject' ], $data );
65+
$message = self::render( $email[ 'body' ], $data );
6666

6767
/**
6868
* Filters the email subject before sending.
@@ -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.
@@ -124,8 +124,8 @@ public static function send( $email_id, $args = array(), $data = array() ) {
124124
public static function register_email( $email_id, $group, $args ) {
125125
self::$emails[ $email_id ] = array(
126126
'group' => $group,
127-
'subject' => $args['subject'],
128-
'body' => $args['body'],
127+
'subject' => $args[ 'subject' ],
128+
'body' => $args[ 'body' ],
129129
);
130130
}
131131

src/wp-includes/pluggable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
448448
try {
449449
$phpmailer->setFrom( $from_email, $from_name, false );
450450
} catch ( PHPMailer\PHPMailer\Exception $e ) {
451-
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
452-
$mail_error_data['phpmailer_exception_code'] = $e->getCode();
451+
$mail_error_data = compact( 'to', 'subject', 'message', 'headers', 'attachments' );
452+
$mail_error_data[ 'phpmailer_exception_code' ] = $e->getCode();
453453

454454
/** This filter is documented in wp-includes/pluggable.php */
455455
do_action( 'wp_mail_failed', new WP_Error( 'wp_mail_failed', $e->getMessage(), $mail_error_data ) );
@@ -476,8 +476,8 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
476476

477477
if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) {
478478
if ( count( $matches ) === 3 ) {
479-
$recipient_name = $matches[1];
480-
$address = $matches[2];
479+
$recipient_name = $matches[ 1 ];
480+
$address = $matches[ 2 ];
481481
}
482482
}
483483

src/wp-includes/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3362,7 +3362,7 @@ function retrieve_password( $user_login = '' ) {
33623362

33633363
$ip_notification = '';
33643364
if ( ! is_user_logged_in() ) {
3365-
$requester_ip = $_SERVER['REMOTE_ADDR'];
3365+
$requester_ip = $_SERVER[ 'REMOTE_ADDR' ];
33663366
if ( $requester_ip ) {
33673367
/* translators: %s: IP address of password reset requester. */
33683368
$ip_notification = sprintf( __( 'This password reset request originated from the IP address %s.' ), $requester_ip );

tests/phpunit/tests/mail/wpMailer.php

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @group mail
44
* @covers WP_Mailer
55
*/
6-
class Tests_Mail_WPMailer extends WP_UnitTestCase {
6+
class Tests_Mail_WP_Mailer extends WP_UnitTestCase {
77

88
public function set_up() {
99
parent::set_up();
@@ -69,7 +69,7 @@ public function test_send_registered_email() {
6969

7070
/**
7171
* Tests the Reply-To fix in wp_mail.
72-
*
72+
*
7373
* @ticket 49661
7474
*/
7575
public function test_wp_mail_reply_to_quoting_fix() {
@@ -80,25 +80,25 @@ public function test_wp_mail_reply_to_quoting_fix() {
8080

8181
wp_mail( $to, $subject, $message, $headers );
8282

83-
$mailer = tests_retrieve_phpmailer_instance();
83+
$mailer = tests_retrieve_phpmailer_instance();
8484
$reply_tos = $mailer->getReplyToAddresses();
85-
85+
8686
$this->assertCount( 1, $reply_tos );
8787
$reply_to = reset( $reply_tos );
88-
88+
8989
// PHPMailer will add its own quotes if needed, but we should not have double quotes here.
90-
$this->assertSame( 'john@example.com', $reply_to[0] );
91-
$this->assertSame( 'John Doe', $reply_to[1] );
90+
$this->assertSame( 'john@example.com', $reply_to[ 0 ] );
91+
$this->assertSame( 'John Doe', $reply_to[ 1 ] );
9292
}
9393

9494
/**
9595
* Tests the retrieve_password template logic.
9696
*/
9797
public function test_retrieve_password_template() {
98-
$site_name = 'My Awesome Site';
98+
$site_name = 'My Awesome Site';
9999
$user_login = 'alice';
100-
$reset_url = 'https://example.com/reset';
101-
$ip = '127.0.0.1';
100+
$reset_url = 'https://example.com/reset';
101+
$ip = '127.0.0.1';
102102

103103
WP_Mailer::register_email(
104104
'retrieve_password',
@@ -131,34 +131,50 @@ public function test_retrieve_password_template() {
131131
* Tests the new_user templates.
132132
*/
133133
public function test_new_user_templates() {
134-
// Admin notification
135-
WP_Mailer::register_email( 'new_user_admin', 'admin', array(
136-
'subject' => '[{{sitename}}] New User',
137-
'body' => 'User: {{user_login}} Email: {{user_email}}',
138-
));
139-
140-
WP_Mailer::send( 'new_user_admin', array( 'to' => 'admin@example.com' ), array(
141-
'sitename' => 'Site',
142-
'user_login' => 'bob',
143-
'user_email' => 'bob@example.com',
144-
) );
134+
// Admin notification.
135+
WP_Mailer::register_email(
136+
'new_user_admin',
137+
'admin',
138+
array(
139+
'subject' => '[{{sitename}}] New User',
140+
'body' => 'User: {{user_login}} Email: {{user_email}}',
141+
)
142+
);
143+
144+
WP_Mailer::send(
145+
'new_user_admin',
146+
array( 'to' => 'admin@example.com' ),
147+
array(
148+
'sitename' => 'Site',
149+
'user_login' => 'bob',
150+
'user_email' => 'bob@example.com',
151+
)
152+
);
145153

146154
$mailer = tests_retrieve_phpmailer_instance();
147155
$this->assertSame( '[Site] New User', $mailer->Subject );
148156
$this->assertStringContainsString( 'User: bob', $mailer->get_sent()->body );
149157

150-
// User notification
158+
// User notification.
151159
reset_phpmailer_instance();
152-
WP_Mailer::register_email( 'new_user', 'user', array(
153-
'subject' => '[{{sitename}}] Login Details',
154-
'body' => 'Login: {{user_login}} URL: {{set_password_url}}',
155-
));
156-
157-
WP_Mailer::send( 'new_user', array( 'to' => 'bob@example.com' ), array(
158-
'sitename' => 'Site',
159-
'user_login' => 'bob',
160-
'set_password_url' => 'http://example.com/set-pw',
161-
) );
160+
WP_Mailer::register_email(
161+
'new_user',
162+
'user',
163+
array(
164+
'subject' => '[{{sitename}}] Login Details',
165+
'body' => 'Login: {{user_login}} URL: {{set_password_url}}',
166+
)
167+
);
168+
169+
WP_Mailer::send(
170+
'new_user',
171+
array( 'to' => 'bob@example.com' ),
172+
array(
173+
'sitename' => 'Site',
174+
'user_login' => 'bob',
175+
'set_password_url' => 'http://example.com/set-pw',
176+
)
177+
);
162178

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

0 commit comments

Comments
 (0)