@@ -47,7 +47,7 @@ function get_url( $params = [] ) {
47
47
* @return string One of 'add', 'edit', 'delete', or '' for default (list)
48
48
*/
49
49
function get_page_action () {
50
- return isset ( $ _GET ['action ' ] ) ? $ _GET ['action ' ] : '' ;
50
+ return isset ( $ _GET ['action ' ] ) ? $ _GET ['action ' ] : '' ; // WPCS: CSRF OK
51
51
}
52
52
53
53
/**
@@ -110,17 +110,18 @@ function render() {
110
110
<?php
111
111
esc_html_e ( 'Registered Applications ' , 'oauth2 ' );
112
112
113
- if ( current_user_can ( 'create_users ' ) ) : ?>
113
+ if ( current_user_can ( 'create_users ' ) ) :
114
+ ?>
114
115
<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>
116
+ class="add-new-h2"><?php echo esc_html_x ( 'Add New ' , 'application ' , 'oauth2 ' ); ?> </a>
116
117
<?php
117
118
endif ;
118
119
?>
119
120
</h2>
120
121
<?php
121
- if ( ! empty ( $ _GET ['deleted ' ] ) ) {
122
+ if ( ! empty ( $ _GET ['deleted ' ] ) ) { // WPCS: CSRF OK
122
123
echo '<div id="message" class="updated"><p> ' . esc_html__ ( 'Deleted application. ' , 'oauth2 ' ) . '</p></div> ' ;
123
- } elseif ( ! empty ( $ _GET ['approved ' ] ) ) {
124
+ } elseif ( ! empty ( $ _GET ['approved ' ] ) ) { // WPCS: CSRF OK
124
125
echo '<div id="message" class="updated"><p> ' . esc_html__ ( 'Approved application. ' , 'oauth2 ' ) . '</p></div> ' ;
125
126
}
126
127
?>
@@ -203,7 +204,7 @@ function handle_edit_submit( Client $consumer = null ) {
203
204
204
205
if ( empty ( $ consumer ) ) {
205
206
// Create the consumer
206
- $ data = [
207
+ $ data = [
207
208
'name ' => $ params ['name ' ],
208
209
'description ' => $ params ['description ' ],
209
210
'meta ' => [
@@ -212,10 +213,11 @@ function handle_edit_submit( Client $consumer = null ) {
212
213
],
213
214
];
214
215
215
- $ consumer = $ result = Client::create ( $ data );
216
+ $ consumer = Client::create ( $ data );
217
+ $ result = $ consumer ;
216
218
} else {
217
219
// Update the existing consumer post
218
- $ data = [
220
+ $ data = [
219
221
'name ' => $ params ['name ' ],
220
222
'description ' => $ params ['description ' ],
221
223
'meta ' => [
@@ -264,12 +266,18 @@ function render_edit_page() {
264
266
wp_die ( __ ( 'Invalid client ID. ' , 'oauth2 ' ) );
265
267
}
266
268
267
- $ form_action = get_url ( [ 'action ' => 'edit ' , 'id ' => $ id ] );
268
- $ regenerate_action = get_url ( [ 'action ' => 'regenerate ' , 'id ' => $ id ] );
269
+ $ form_action = get_url ( [
270
+ 'action ' => 'edit ' ,
271
+ 'id ' => $ id ,
272
+ ] );
273
+ $ regenerate_action = get_url ( [
274
+ 'action ' => 'regenerate ' ,
275
+ 'id ' => $ id ,
276
+ ] );
269
277
}
270
278
271
279
// Handle form submission
272
- $ messages = [];
280
+ $ messages = [];
273
281
$ form_data = [];
274
282
if ( ! empty ( $ _POST ['_wpnonce ' ] ) ) {
275
283
if ( empty ( $ consumer ) ) {
@@ -278,7 +286,7 @@ function render_edit_page() {
278
286
check_admin_referer ( 'rest-oauth2-edit- ' . $ consumer ->get_post_id () );
279
287
}
280
288
281
- $ messages = handle_edit_submit ( $ consumer );
289
+ $ messages = handle_edit_submit ( $ consumer );
282
290
$ form_data = wp_unslash ( $ _POST );
283
291
}
284
292
if ( ! empty ( $ _GET ['did_action ' ] ) ) {
@@ -371,10 +379,12 @@ function render_edit_page() {
371
379
<?php echo esc_html_x ( 'Private ' , 'Client type select option ' , 'oauth2 ' ); ?>
372
380
</label>
373
381
<p class="description">
374
- <?php esc_html_e (
382
+ <?php
383
+ esc_html_e (
375
384
'Clients capable of maintaining confidentiality of credentials, such as server-side applications ' ,
376
385
'oauth2 '
377
- ) ?>
386
+ );
387
+ ?>
378
388
</p>
379
389
</li>
380
390
<li>
@@ -389,10 +399,12 @@ function render_edit_page() {
389
399
<?php echo esc_html_x ( 'Public ' , 'Client type select option ' , 'oauth2 ' ); ?>
390
400
</label>
391
401
<p class="description">
392
- <?php esc_html_e (
402
+ <?php
403
+ esc_html_e (
393
404
'Clients incapable of keeping credentials secret, such as browser-based applications or desktop and mobile apps ' ,
394
405
'oauth2 '
395
- ) ?>
406
+ );
407
+ ?>
396
408
</p>
397
409
</li>
398
410
</ul>
@@ -552,6 +564,10 @@ function handle_regenerate() {
552
564
wp_die ( $ result ->get_error_message () );
553
565
}
554
566
555
- wp_safe_redirect ( get_url ( [ 'action ' => 'edit ' , 'id ' => $ id , 'did_action ' => 'regenerate ' ] ) );
567
+ wp_safe_redirect ( get_url ( [
568
+ 'action ' => 'edit ' ,
569
+ 'id ' => $ id ,
570
+ 'did_action ' => 'regenerate ' ,
571
+ ] ) );
556
572
exit ;
557
573
}
0 commit comments