Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Commit c63ca67

Browse files
committed
WordPress Coding Standard fixes
1 parent 6cc6f60 commit c63ca67

File tree

10 files changed

+840
-678
lines changed

10 files changed

+840
-678
lines changed

admin_panels.php

Lines changed: 449 additions & 330 deletions
Large diffs are not rendered by default.

comments.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ function openid_process_comment( $comment ) {
7373
unset( $_SESSION['openid_posted_comment'] );
7474

7575
if ( ! empty( $openid_url ) ) { // Comment form's OpenID url is filled in.
76-
$_SESSION['openid_comment_post'] = $_POST;
76+
$_SESSION['openid_comment_post'] = $_POST;
7777
$_SESSION['openid_comment_post']['comment_author_openid'] = $openid_url;
78-
$_SESSION['openid_comment_post']['openid_skip'] = 1;
78+
$_SESSION['openid_comment_post']['openid_skip'] = 1;
7979

8080
openid_start_login( $openid_url, 'comment' );
8181

@@ -102,8 +102,8 @@ function openid_process_comment( $comment ) {
102102
* address.
103103
*/
104104
function openid_require_name_email( $comment ) {
105-
$user = wp_get_current_user();
106-
$comment_author = $comment['comment_author'];
105+
$user = wp_get_current_user();
106+
$comment_author = $comment['comment_author'];
107107
$comment_author_email = $comment['comment_author_email'];
108108

109109
if ( get_option( 'require_name_email' ) && ! $user->ID ) {
@@ -185,9 +185,11 @@ function openid_sanitize_comment_cookies() {
185185
// this might be an i-name, so we don't want to run clean_url()
186186
remove_filter( 'pre_comment_author_url', 'clean_url' );
187187

188-
$comment_author_url = apply_filters( 'pre_comment_author_url',
189-
$_COOKIE[ 'comment_author_openid_' . COOKIEHASH ] );
190-
$comment_author_url = stripslashes( $comment_author_url );
188+
$comment_author_url = apply_filters(
189+
'pre_comment_author_url',
190+
$_COOKIE[ 'comment_author_openid_' . COOKIEHASH ]
191+
);
192+
$comment_author_url = stripslashes( $comment_author_url );
191193
$_COOKIE[ 'comment_author_url_' . COOKIEHASH ] = $comment_author_url;
192194
}
193195
}
@@ -343,7 +345,7 @@ function openid_finish_comment( $identity_url, $action ) {
343345
* @param int $id id of comment to set as OpenID
344346
*/
345347
function set_comment_openid( $id ) {
346-
$comment = get_comment( $id );
348+
$comment = get_comment( $id );
347349
$openid_comments = get_post_meta( $comment->comment_post_ID, 'openid_comments', true );
348350
if ( ! is_array( $openid_comments ) ) {
349351
$openid_comments = array();
@@ -359,7 +361,7 @@ function set_comment_openid( $id ) {
359361
* @param int $id id of comment to set as OpenID
360362
*/
361363
function unset_comment_openid( $id ) {
362-
$comment = get_comment( $id );
364+
$comment = get_comment( $id );
363365
$openid_comments = get_post_meta( $comment->comment_post_ID, 'openid_comments', true );
364366

365367
if ( is_array( $openid_comments ) && in_array( $id, $openid_comments ) ) {
@@ -396,9 +398,9 @@ function openid_get_user_data_form( $data, $identity_url ) {
396398
}
397399

398400
if ( $comment['author'] ) {
399-
$data['nickname'] = $comment['author'];
401+
$data['nickname'] = $comment['author'];
400402
$data['user_nicename'] = $comment['author'];
401-
$data['display_name'] = $comment['author'];
403+
$data['display_name'] = $comment['author'];
402404
}
403405

404406
return $data;

common.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ function openid_customer_error_handler( $errno, $errmsg, $filename, $linenum, $v
232232
*/
233233
function openid_generate_new_username( $url, $append = true ) {
234234
$base = openid_normalize_username( $url );
235-
$i = '';
235+
$i = '';
236236
while ( true ) {
237237
$username = openid_normalize_username( $base . $i );
238-
$user = get_user_by( 'login', $username );
238+
$user = get_user_by( 'login', $username );
239239
if ( $user ) {
240240
if ( ! $append ) {
241241
return null;
@@ -349,25 +349,25 @@ function openid_create_new_user( $identity_url, &$user_data ) {
349349
$username = openid_generate_new_username( $identity_url );
350350
}
351351

352-
$user_data['user_login'] = $username;
352+
$user_data['user_login'] = $username;
353353
$user_data['display_name'] = $username;
354-
$user_data['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 7 );
355-
$user_id = wp_insert_user( $user_data );
354+
$user_data['user_pass'] = substr( md5( uniqid( microtime() ) ), 0, 7 );
355+
$user_id = wp_insert_user( $user_data );
356356

357357
if ( $user_id instanceof WP_Error ) {
358358
openid_message( $user_id->get_error_message() );
359359
openid_status( 'error' );
360360
return;
361-
} else if ( is_integer( $user_id ) ) { // created ok
361+
} elseif ( is_integer( $user_id ) ) { // created ok
362362

363363
$user_data['ID'] = $user_id;
364364
// XXX this all looks redundant, see openid_set_current_user
365365

366-
$user = new WP_User( $user_id );
366+
$user = new WP_User( $user_id );
367367
$credentials = array(
368-
'user_login' => $user->user_login,
368+
'user_login' => $user->user_login,
369369
'user_password' => $user_data['user_pass'],
370-
'remember' => true,
370+
'remember' => true,
371371
);
372372

373373
if ( ! wp_signon( $credentials ) ) {
@@ -419,10 +419,10 @@ function openid_create_new_user( $identity_url, &$user_data ) {
419419
*/
420420
function openid_get_user_data( $identity_url ) {
421421
$data = array(
422-
'ID' => null,
423-
'user_url' => $identity_url,
422+
'ID' => null,
423+
'user_url' => $identity_url,
424424
'user_nicename' => $identity_url,
425-
'display_name' => $identity_url,
425+
'display_name' => $identity_url,
426426
);
427427

428428
// create proper website URL if OpenID is an i-name
@@ -462,7 +462,7 @@ function openid_get_user_data_ax( $data, $identity_url ) {
462462
require_once( 'Auth/OpenID/AX.php' );
463463

464464
$response = openid_response();
465-
$ax = Auth_OpenID_AX_FetchResponse::fromSuccessResponse( $response );
465+
$ax = Auth_OpenID_AX_FetchResponse::fromSuccessResponse( $response );
466466

467467
if ( ! $ax ) {
468468
return $data;
@@ -475,9 +475,9 @@ function openid_get_user_data_ax( $data, $identity_url ) {
475475

476476
$nickname = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
477477
if ( $nickname && ! is_a( $nickname, 'Auth_OpenID_AX_Error' ) ) {
478-
$data['nickname'] = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
478+
$data['nickname'] = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
479479
$data['user_nicename'] = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
480-
$data['display_name'] = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
480+
$data['display_name'] = $ax->getSingle( 'http://axschema.org/namePerson/friendly' );
481481
}
482482

483483
$fullname = $ax->getSingle( 'http://axschema.org/namePerson' );
@@ -505,9 +505,9 @@ function openid_get_user_data_ax( $data, $identity_url ) {
505505
*/
506506
function openid_get_user_data_sreg( $data, $identity_url ) {
507507
require_once( 'Auth/OpenID/SReg.php' );
508-
$response = openid_response();
508+
$response = openid_response();
509509
$sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse( $response );
510-
$sreg = $sreg_resp->contents();
510+
$sreg = $sreg_resp->contents();
511511

512512
if ( ! $sreg ) {
513513
return $data;
@@ -518,9 +518,9 @@ function openid_get_user_data_sreg( $data, $identity_url ) {
518518
}
519519

520520
if ( array_key_exists( 'nickname', $sreg ) && $sreg['nickname'] ) {
521-
$data['nickname'] = $sreg['nickname'];
521+
$data['nickname'] = $sreg['nickname'];
522522
$data['user_nicename'] = $sreg['nickname'];
523-
$data['display_name'] = $sreg['nickname'];
523+
$data['display_name'] = $sreg['nickname'];
524524
}
525525

526526
if ( array_key_exists( 'fullname', $sreg ) && $sreg['fullname'] ) {
@@ -625,7 +625,7 @@ function openid_clean_request() {
625625

626626
unset( $_GET['q'] );
627627

628-
$vars = explode( '&', $_SERVER['QUERY_STRING'] );
628+
$vars = explode( '&', $_SERVER['QUERY_STRING'] );
629629
$clean = array();
630630

631631
foreach ( $vars as $v ) {
@@ -642,7 +642,7 @@ function openid_clean_request() {
642642
// This results in the QUERY_STRING not having the correct information, but fortunately we
643643
// can pull it out of REQUEST_URI
644644

645-
list($path, $query) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
645+
list($path, $query) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
646646
$_SERVER['QUERY_STRING'] = $query;
647647
}
648648
}

consumer.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function openid_getConsumer() { // phpcs:ignore
2121
if ( ! $consumer ) {
2222
require_once 'Auth/OpenID/Consumer.php';
2323

24-
$store = openid_getStore();
24+
$store = openid_getStore();
2525
$consumer = new Auth_OpenID_Consumer( $store );
2626
if ( null === $consumer ) {
2727
openid_error( 'OpenID consumer could not be created properly.' );
@@ -98,7 +98,7 @@ function finish_openid_auth() {
9898
openid_status( 'success' );
9999

100100
$identity_url = $response->identity_url;
101-
$escaped_url = htmlspecialchars( $identity_url, ENT_QUOTES );
101+
$escaped_url = htmlspecialchars( $identity_url, ENT_QUOTES );
102102
return $escaped_url;
103103

104104
default:
@@ -124,7 +124,7 @@ function openid_begin_consumer( $url ) {
124124
set_error_handler( 'openid_customer_error_handler' );
125125

126126
$consumer = openid_getConsumer();
127-
$request = $consumer->begin( $url );
127+
$request = $consumer->begin( $url );
128128

129129
restore_error_handler();
130130
}
@@ -150,16 +150,18 @@ function openid_start_login( $claimed_url, $action, $finish_url = null ) {
150150

151151
if ( null === $auth_request ) {
152152
openid_status( 'error' );
153-
openid_message(sprintf(
154-
__( 'Could not discover an OpenID identity server endpoint at the url: %s', 'openid' ),
155-
htmlentities( $claimed_url )
156-
));
153+
openid_message(
154+
sprintf(
155+
__( 'Could not discover an OpenID identity server endpoint at the url: %s', 'openid' ),
156+
htmlentities( $claimed_url )
157+
)
158+
);
157159

158160
return;
159161
}
160162

161163
@session_start();
162-
$_SESSION['openid_action'] = $action;
164+
$_SESSION['openid_action'] = $action;
163165
$_SESSION['openid_finish_url'] = $finish_url;
164166

165167
$extensions = apply_filters( 'openid_auth_request_extensions', array(), $auth_request );
@@ -192,7 +194,7 @@ function openid_add_ax_extension( $extensions, $auth_request ) {
192194
Auth_OpenID_AX_AttrInfo::make( 'http://axschema.org/contact/email', 1, true ),
193195
Auth_OpenID_AX_AttrInfo::make( 'http://axschema.org/namePerson', 1, true ),
194196
);
195-
$fields = apply_filters( 'openid_consumer_ax_fields', $default_fields );
197+
$fields = apply_filters( 'openid_consumer_ax_fields', $default_fields );
196198

197199
$ax_request = new Auth_OpenID_AX_FetchRequest();
198200
foreach ( $fields as $field ) {
@@ -218,8 +220,8 @@ function openid_add_sreg_extension( $extensions, $auth_request ) {
218220
require_once( 'Auth/OpenID/SReg.php' );
219221

220222
if ( $auth_request->endpoint->usesExtension( Auth_OpenID_SREG_NS_URI_1_0 ) || $auth_request->endpoint->usesExtension( Auth_OpenID_SREG_NS_URI_1_1 ) ) {
221-
$required = apply_filters( 'openid_consumer_sreg_required_fields', array() );
222-
$optional = apply_filters( 'openid_consumer_sreg_optional_fields', array( 'nickname', 'email', 'fullname' ) );
223+
$required = apply_filters( 'openid_consumer_sreg_required_fields', array() );
224+
$optional = apply_filters( 'openid_consumer_sreg_optional_fields', array( 'nickname', 'email', 'fullname' ) );
223225
$extensions[] = Auth_OpenID_SRegRequest::build( $required, $optional );
224226
}
225227
}

0 commit comments

Comments
 (0)