Skip to content

Commit a8af26d

Browse files
committed
Correct spacing
1 parent 25941a7 commit a8af26d

13 files changed

+76
-61
lines changed

inc/admin/class-listtable.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function get_columns() {
5656
public function column_cb( $item ) {
5757
?>
5858
<label class="screen-reader-text"
59-
for="cb-select-<?php echo esc_attr( $item->ID ) ?>"><?php esc_html_e( 'Select consumer', 'oauth2' ); ?></label>
59+
for="cb-select-<?php echo esc_attr( $item->ID ); ?>"><?php esc_html_e( 'Select consumer', 'oauth2' ); ?></label>
6060

6161
<input id="cb-select-<?php echo esc_attr( $item->ID ) ?>" type="checkbox"
62-
name="consumers[]" value="<?php echo esc_attr( $item->ID ) ?>"/>
62+
name="consumers[]" value="<?php echo esc_attr( $item->ID ); ?>"/>
6363

6464
<?php
6565
}
@@ -92,7 +92,7 @@ protected function column_name( $item ) {
9292
);
9393
$delete_link = wp_nonce_url( $delete_link, 'rest-oauth2-delete:' . $item->ID );
9494

95-
$actions = [
95+
$actions = [
9696
'edit' => sprintf( '<a href="%s">%s</a>', esc_url( $edit_link ), esc_html__( 'Edit', 'oauth2' ) ),
9797
'delete' => sprintf( '<a href="%s">%s</a>', esc_url( $delete_link ), esc_html__( 'Delete', 'oauth2' ) ),
9898
];
@@ -101,13 +101,14 @@ protected function column_name( $item ) {
101101
if ( current_user_can( $post_type_object->cap->publish_posts ) && $item->post_status !== 'publish' ) {
102102
$publish_link = add_query_arg(
103103
[
104-
'page' => 'rest-oauth2-apps',
104+
'page' => 'rest-oauth2-apps',
105105
'action' => 'approve',
106-
'id' => $item->ID,
106+
'id' => $item->ID,
107107
],
108108
admin_url( 'users.php' )
109109
);
110-
$publish_link = wp_nonce_url( $publish_link, 'rest-oauth2-approve:' . $item->ID );
110+
111+
$publish_link = wp_nonce_url( $publish_link, 'rest-oauth2-approve:' . $item->ID );
111112
$actions['app-approve'] = sprintf(
112113
'<a href="%s">%s</a>',
113114
esc_url( $publish_link ),

inc/admin/namespace.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function render() {
112112

113113
if ( current_user_can( 'create_users' ) ) : ?>
114114
<a href="<?php echo esc_url( get_url( 'action=add' ) ) ?>"
115-
class="add-new-h2"><?php echo esc_html_x( 'Add New', 'application', 'oauth2' ); ?></a>
115+
class="add-new-h2"><?php echo esc_html_x( 'Add New', 'application', 'oauth2' ); ?></a>
116116
<?php
117117
endif;
118118
?>
@@ -203,7 +203,7 @@ function handle_edit_submit( Client $consumer = null ) {
203203

204204
if ( empty( $consumer ) ) {
205205
// Create the consumer
206-
$data = [
206+
$data = [
207207
'name' => $params['name'],
208208
'description' => $params['description'],
209209
'meta' => [
@@ -212,10 +212,11 @@ function handle_edit_submit( Client $consumer = null ) {
212212
],
213213
];
214214

215-
$consumer = $result = Client::create( $data );
215+
$consumer = Client::create( $data );
216+
$result = $consumer;
216217
} else {
217218
// Update the existing consumer post
218-
$data = [
219+
$data = [
219220
'name' => $params['name'],
220221
'description' => $params['description'],
221222
'meta' => [
@@ -264,12 +265,18 @@ function render_edit_page() {
264265
wp_die( __( 'Invalid client ID.', 'oauth2' ) );
265266
}
266267

267-
$form_action = get_url( [ 'action' => 'edit', 'id' => $id ] );
268-
$regenerate_action = get_url( [ 'action' => 'regenerate', 'id' => $id ] );
268+
$form_action = get_url( [
269+
'action' => 'edit',
270+
'id' => $id,
271+
] );
272+
$regenerate_action = get_url( [
273+
'action' => 'regenerate',
274+
'id' => $id,
275+
] );
269276
}
270277

271278
// Handle form submission
272-
$messages = [];
279+
$messages = [];
273280
$form_data = [];
274281
if ( ! empty( $_POST['_wpnonce'] ) ) {
275282
if ( empty( $consumer ) ) {
@@ -278,7 +285,7 @@ function render_edit_page() {
278285
check_admin_referer( 'rest-oauth2-edit-' . $consumer->get_post_id() );
279286
}
280287

281-
$messages = handle_edit_submit( $consumer );
288+
$messages = handle_edit_submit( $consumer );
282289
$form_data = wp_unslash( $_POST );
283290
}
284291
if ( ! empty( $_GET['did_action'] ) ) {
@@ -371,10 +378,12 @@ function render_edit_page() {
371378
<?php echo esc_html_x( 'Private', 'Client type select option', 'oauth2' ); ?>
372379
</label>
373380
<p class="description">
374-
<?php esc_html_e(
381+
<?php
382+
esc_html_e(
375383
'Clients capable of maintaining confidentiality of credentials, such as server-side applications',
376384
'oauth2'
377-
) ?>
385+
);
386+
?>
378387
</p>
379388
</li>
380389
<li>
@@ -389,10 +398,12 @@ function render_edit_page() {
389398
<?php echo esc_html_x( 'Public', 'Client type select option', 'oauth2' ); ?>
390399
</label>
391400
<p class="description">
392-
<?php esc_html_e(
401+
<?php
402+
esc_html_e(
393403
'Clients incapable of keeping credentials secret, such as browser-based applications or desktop and mobile apps',
394404
'oauth2'
395-
) ?>
405+
);
406+
?>
396407
</p>
397408
</li>
398409
</ul>
@@ -552,6 +563,10 @@ function handle_regenerate() {
552563
wp_die( $result->get_error_message() );
553564
}
554565

555-
wp_safe_redirect( get_url( [ 'action' => 'edit', 'id' => $id, 'did_action' => 'regenerate' ] ) );
566+
wp_safe_redirect( get_url( [
567+
'action' => 'edit',
568+
'id' => $id,
569+
'did_action' => 'regenerate',
570+
] ) );
556571
exit;
557572
}

inc/admin/profile/namespace.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function bootstrap() {
1515
add_action( 'show_user_profile', __NAMESPACE__ . '\\render_profile_section' );
1616
add_action( 'edit_user_profile', __NAMESPACE__ . '\\render_profile_section' );
1717
add_action( 'all_admin_notices', __NAMESPACE__ . '\\output_profile_messages' );
18-
add_action( 'personal_options_update', __NAMESPACE__ . '\\handle_revocation', 10, 1 );
18+
add_action( 'personal_options_update', __NAMESPACE__ . '\\handle_revocation', 10, 1 );
1919
add_action( 'edit_user_profile_update', __NAMESPACE__ . '\\handle_revocation', 10, 1 );
2020
}
2121

@@ -77,15 +77,15 @@ function render_token_row( WP_User $user, Access_Token $token ) {
7777
* @param Access_Token $token Token being displayed.
7878
* @param WP_User $user User whose profile is being rendered.
7979
*/
80-
$details = apply_filters( 'oauth2.admin.profile.render_token_row.details', $details, $token, $user );
80+
$details = apply_filters( 'oauth2.admin.profile.render_token_row.details', $details, $token, $user );
8181

8282
// Build actions.
8383
$button_title = sprintf(
8484
/* translators: %s: app name */
8585
__( 'Revoke access for "%s"', 'oauth2' ),
8686
$client->get_name()
8787
);
88-
$actions = [
88+
$actions = [
8989
sprintf(
9090
'<button class="button" name="oauth2_revoke" title="%s" value="%s">%s</button>',
9191
$button_title,
@@ -156,7 +156,6 @@ function handle_revocation( $user_id ) {
156156

157157
$token = Access_Token::get_by_id( $key );
158158
if ( empty( $token ) ) {
159-
var_dump( $key, $token );
160159
wp_safe_redirect( add_query_arg( 'oauth2_revocation_failed', true, get_edit_user_link( $user_id ) ) );
161160
exit;
162161
}

inc/authentication/namespace.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ function attempt_authentication( $user = null ) {
116116

117117
// Attempt to find the token.
118118
$is_querying_token = true;
119-
$token = Tokens\get_by_id( $token_value );
120-
$client = $token->get_client();
119+
$token = Tokens\get_by_id( $token_value );
120+
$client = $token->get_client();
121121
$is_querying_token = false;
122122

123123
if ( empty( $token ) || empty( $client ) ) {

inc/class-client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function get_description( $raw = false ) {
7373
// Replicate the_content()'s filters.
7474
global $post;
7575
$current_post = $post;
76-
$the_post = get_post( $this->get_post_id() );
76+
$the_post = get_post( $this->get_post_id() );
7777
if ( $raw ) {
7878
// Skip the filtering and globals.
7979
return $the_post->post_content;
@@ -168,7 +168,7 @@ public function check_redirect_uri( $uri ) {
168168
return false;
169169
}
170170

171-
$supplied = wp_parse_url( $uri );
171+
$supplied = wp_parse_url( $uri );
172172
$all_registered = $this->get_redirect_uris();
173173

174174
foreach ( $all_registered as $registered_uri ) {
@@ -273,7 +273,7 @@ public function issue_token( WP_User $user ) {
273273
* @return static|null Token if ID is found, null otherwise.
274274
*/
275275
public static function get_by_id( $id ) {
276-
$args = [
276+
$args = [
277277
'post_type' => static::POST_TYPE,
278278
'post_status' => 'publish',
279279
'posts_per_page' => 1,
@@ -366,8 +366,8 @@ public function update( $data ) {
366366
}
367367

368368
$meta = [
369-
static::REDIRECT_URI_KEY => $data['meta']['callback'],
370-
static::TYPE_KEY => $data['meta']['type'],
369+
static::REDIRECT_URI_KEY => $data['meta']['callback'],
370+
static::TYPE_KEY => $data['meta']['type'],
371371
];
372372

373373
foreach ( $meta as $key => $value ) {
@@ -394,8 +394,8 @@ public function delete() {
394394
* @return bool|WP_Error True if client was updated, error otherwise.
395395
*/
396396
public function approve() {
397-
$data = [
398-
'ID' => $this->get_post_id(),
397+
$data = [
398+
'ID' => $this->get_post_id(),
399399
'post_status' => 'publish',
400400
];
401401
$result = wp_update_post( wp_slash( $data ), true );

inc/endpoints/class-token.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313
class Token {
1414
public function register_routes() {
1515
register_rest_route( 'oauth2', '/access_token', [
16-
'methods' => 'POST',
16+
'methods' => 'POST',
1717
'callback' => [ $this, 'exchange_token' ],
18-
'args' => [
18+
'args' => [
1919
'grant_type' => [
20-
'required' => true,
21-
'type' => 'string',
20+
'required' => true,
21+
'type' => 'string',
2222
'validate_callback' => [ $this, 'validate_grant_type' ],
2323
],
2424
'client_id' => [
25-
'required' => true,
26-
'type' => 'string',
25+
'required' => true,
26+
'type' => 'string',
2727
'validate_callback' => 'rest_validate_request_arg',
2828
],
2929
'code' => [
30-
'required' => true,
31-
'type' => 'string',
30+
'required' => true,
31+
'type' => 'string',
3232
'validate_callback' => 'rest_validate_request_arg',
3333
],
3434
],
@@ -60,7 +60,7 @@ public function exchange_token( WP_REST_Request $request ) {
6060
'oauth2.endpoints.token.exchange_token.invalid_client',
6161
sprintf( __( 'Client ID %s is invalid.', 'oauth2' ), $request['client_id'] ),
6262
[
63-
'status' => WP_Http::BAD_REQUEST,
63+
'status' => WP_Http::BAD_REQUEST,
6464
'client_id' => $request['client_id'],
6565
]
6666
);

inc/endpoints/namespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function register() {
1515

1616
// Register convenience URL.
1717
register_rest_route( 'oauth2', '/authorize', [
18-
'methods' => 'GET',
18+
'methods' => 'GET',
1919
'callback' => __NAMESPACE__ . '\\redirect_to_authorize',
2020
]);
2121
}

inc/namespace.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function get_grant_types() {
7373
*/
7474
function register_grant_types( $types ) {
7575
$types['authorization_code'] = new Types\Authorization_Code();
76-
$types['implicit'] = new Types\Implicit();
76+
$types['implicit'] = new Types\Implicit();
7777

7878
return $types;
7979
}
@@ -88,9 +88,9 @@ function register_in_index( WP_REST_Response $response ) {
8888
$data = $response->get_data();
8989

9090
$data['authentication']['oauth2'] = [
91-
'endpoints' => [
91+
'endpoints' => [
9292
'authorization' => get_authorization_url(),
93-
'token' => get_token_url(),
93+
'token' => get_token_url(),
9494
],
9595
'grant_types' => array_keys( get_grant_types() ),
9696
];

inc/tokens/class-access-token.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Access_Token extends Token {
1111
const META_PREFIX = '_oauth2_access_';
12-
const KEY_LENGTH = 12;
12+
const KEY_LENGTH = 12;
1313

1414
/**
1515
* @return string Meta prefix.
@@ -105,7 +105,7 @@ public static function get_for_user( WP_User $user ) {
105105
}
106106

107107
$real_key = substr( $key, strlen( static::META_PREFIX ) );
108-
$value = maybe_unserialize( $values[0] );
108+
$value = maybe_unserialize( $values[0] );
109109
$tokens[] = new static( $user, $real_key, $value );
110110
}
111111
return $tokens;
@@ -131,7 +131,7 @@ public static function create( Client $client, WP_User $user ) {
131131
'client' => $client->get_id(),
132132
'created' => time(),
133133
];
134-
$key = wp_generate_password( static::KEY_LENGTH, false );
134+
$key = wp_generate_password( static::KEY_LENGTH, false );
135135
$meta_key = static::META_PREFIX . $key;
136136

137137
$result = add_user_meta( $user->ID, wp_slash( $meta_key ), wp_slash( $data ), true );

inc/tokens/class-authorization-code.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Authorization_Code {
3737
*/
3838
public function __construct( Client $client, $code ) {
3939
$this->client = $client;
40-
$this->code = $code;
40+
$this->code = $code;
4141
}
4242

4343
/**
@@ -116,15 +116,15 @@ public function get_expiration() {
116116
*/
117117
public function validate( $args = [] ) {
118118
$expiration = $this->get_expiration();
119-
$now = time();
119+
$now = time();
120120
if ( $expiration <= $now ) {
121121
return new WP_Error(
122122
'oauth2.tokens.authorization_code.validate.expired',
123123
__( 'Authorization code has expired.', 'oauth2' ),
124124
[
125-
'status' => WP_Http::BAD_REQUEST,
125+
'status' => WP_Http::BAD_REQUEST,
126126
'expiration' => $expiration,
127-
'time' => $now,
127+
'time' => $now,
128128
]
129129
);
130130
}
@@ -158,7 +158,7 @@ public function delete() {
158158
* @return Authorization_Code|WP_Error Authorization code instance, or error on failure.
159159
*/
160160
public static function get_by_code( Client $client, $code ) {
161-
$key = static::KEY_PREFIX . $code;
161+
$key = static::KEY_PREFIX . $code;
162162
$value = get_post_meta( $client->get_post_id(), wp_slash( $key ), false );
163163
if ( empty( $value ) ) {
164164
return new WP_Error(
@@ -184,13 +184,13 @@ public static function get_by_code( Client $client, $code ) {
184184
* @return Authorization_Code|WP_Error Authorization code instance, or error on failure.
185185
*/
186186
public static function create( Client $client, WP_User $user ) {
187-
$code = wp_generate_password( static::KEY_LENGTH, false );
187+
$code = wp_generate_password( static::KEY_LENGTH, false );
188188
$meta_key = static::KEY_PREFIX . $code;
189-
$data = [
189+
$data = [
190190
'user' => (int) $user->ID,
191191
'expiration' => time() + static::MAX_AGE,
192192
];
193-
$result = add_post_meta( $client->get_post_id(), wp_slash( $meta_key ), wp_slash( $data ), true );
193+
$result = add_post_meta( $client->get_post_id(), wp_slash( $meta_key ), wp_slash( $data ), true );
194194
if ( ! $result ) {
195195
return new WP_Error(
196196
'oauth2.tokens.authorization_code.create.could_not_create',

0 commit comments

Comments
 (0)