@@ -47,7 +47,7 @@ function get_url( $params = [] ) {
4747 * @return string One of 'add', 'edit', 'delete', or '' for default (list)
4848 */
4949function get_page_action () {
50- return isset ( $ _GET ['action ' ] ) ? $ _GET ['action ' ] : '' ;
50+ return isset ( $ _GET ['action ' ] ) ? $ _GET ['action ' ] : '' ; // WPCS: CSRF OK
5151}
5252
5353/**
@@ -110,17 +110,18 @@ function render() {
110110 <?php
111111 esc_html_e ( 'Registered Applications ' , 'oauth2 ' );
112112
113- if ( current_user_can ( 'create_users ' ) ) : ?>
113+ if ( current_user_can ( 'create_users ' ) ) :
114+ ?>
114115 <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>
116117 <?php
117118 endif ;
118119 ?>
119120 </h2>
120121 <?php
121- if ( ! empty ( $ _GET ['deleted ' ] ) ) {
122+ if ( ! empty ( $ _GET ['deleted ' ] ) ) { // WPCS: CSRF OK
122123 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
124125 echo '<div id="message" class="updated"><p> ' . esc_html__ ( 'Approved application. ' , 'oauth2 ' ) . '</p></div> ' ;
125126 }
126127 ?>
@@ -203,7 +204,7 @@ function handle_edit_submit( Client $consumer = null ) {
203204
204205 if ( empty ( $ consumer ) ) {
205206 // Create the consumer
206- $ data = [
207+ $ data = [
207208 'name ' => $ params ['name ' ],
208209 'description ' => $ params ['description ' ],
209210 'meta ' => [
@@ -212,10 +213,11 @@ function handle_edit_submit( Client $consumer = null ) {
212213 ],
213214 ];
214215
215- $ consumer = $ result = Client::create ( $ data );
216+ $ consumer = Client::create ( $ data );
217+ $ result = $ consumer ;
216218 } else {
217219 // Update the existing consumer post
218- $ data = [
220+ $ data = [
219221 'name ' => $ params ['name ' ],
220222 'description ' => $ params ['description ' ],
221223 'meta ' => [
@@ -264,12 +266,18 @@ function render_edit_page() {
264266 wp_die ( __ ( 'Invalid client ID. ' , 'oauth2 ' ) );
265267 }
266268
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+ ] );
269277 }
270278
271279 // Handle form submission
272- $ messages = [];
280+ $ messages = [];
273281 $ form_data = [];
274282 if ( ! empty ( $ _POST ['_wpnonce ' ] ) ) {
275283 if ( empty ( $ consumer ) ) {
@@ -278,7 +286,7 @@ function render_edit_page() {
278286 check_admin_referer ( 'rest-oauth2-edit- ' . $ consumer ->get_post_id () );
279287 }
280288
281- $ messages = handle_edit_submit ( $ consumer );
289+ $ messages = handle_edit_submit ( $ consumer );
282290 $ form_data = wp_unslash ( $ _POST );
283291 }
284292 if ( ! empty ( $ _GET ['did_action ' ] ) ) {
@@ -371,10 +379,12 @@ function render_edit_page() {
371379 <?php echo esc_html_x ( 'Private ' , 'Client type select option ' , 'oauth2 ' ); ?>
372380 </label>
373381 <p class="description">
374- <?php esc_html_e (
382+ <?php
383+ esc_html_e (
375384 'Clients capable of maintaining confidentiality of credentials, such as server-side applications ' ,
376385 'oauth2 '
377- ) ?>
386+ );
387+ ?>
378388 </p>
379389 </li>
380390 <li>
@@ -389,10 +399,12 @@ function render_edit_page() {
389399 <?php echo esc_html_x ( 'Public ' , 'Client type select option ' , 'oauth2 ' ); ?>
390400 </label>
391401 <p class="description">
392- <?php esc_html_e (
402+ <?php
403+ esc_html_e (
393404 'Clients incapable of keeping credentials secret, such as browser-based applications or desktop and mobile apps ' ,
394405 'oauth2 '
395- ) ?>
406+ );
407+ ?>
396408 </p>
397409 </li>
398410 </ul>
@@ -552,6 +564,10 @@ function handle_regenerate() {
552564 wp_die ( $ result ->get_error_message () );
553565 }
554566
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+ ] ) );
556572 exit ;
557573}
0 commit comments