' . esc_html__( 'Deleted application.', 'oauth2' ) . '
'; - } elseif ( ! empty( $_GET['approved'] ) ) { // WPCS: CSRF OK + } elseif ( ! empty( $_GET['approved'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended echo '' . esc_html__( 'Approved application.', 'oauth2' ) . '
' . __( 'You are not allowed to delete this application.', 'oauth2' ) . '
', + '' . esc_html__( 'You are not allowed to delete this application.', 'oauth2' ) . '
', 403 ); } $client = Client::get_by_post_id( $id ); if ( is_wp_error( $client ) ) { - wp_die( $client ); + wp_die( $client ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return; } if ( ! $client->delete() ) { - $message = 'Invalid client ID'; - wp_die( $message ); + wp_die( esc_html__( 'Invalid client ID' ) ); return; } @@ -519,20 +531,20 @@ function handle_approve() { if ( ! current_user_can( 'publish_post', $id ) ) { wp_die( - '' . __( 'You are not allowed to approve this application.', 'oauth2' ) . '
', + '' . esc_html__( 'You are not allowed to approve this application.', 'oauth2' ) . '
', 403 ); } $client = Client::get_by_post_id( $id ); if ( is_wp_error( $client ) ) { - wp_die( $client ); + wp_die( $client ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } $did_approve = $client->approve(); if ( is_wp_error( $did_approve ) ) { - wp_die( $did_approve ); + wp_die( $did_approve ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } wp_safe_redirect( get_url( 'approved=1' ) ); @@ -552,8 +564,8 @@ function handle_regenerate() { if ( ! current_user_can( 'edit_post', $id ) ) { wp_die( - '' . __( 'You are not allowed to edit this application.', 'oauth2' ) . '
', + '' . esc_html__( 'You are not allowed to edit this application.', 'oauth2' ) . '
', 403 ); } @@ -561,13 +573,17 @@ function handle_regenerate() { $client = Client::get_by_post_id( $id ); $result = $client->regenerate_secret(); if ( is_wp_error( $result ) ) { - wp_die( $result->get_error_message() ); + wp_die( esc_html( $result->get_error_message() ) ); } - wp_safe_redirect( get_url( [ - 'action' => 'edit', - 'id' => $id, - 'did_action' => 'regenerate', - ] ) ); + wp_safe_redirect( + get_url( + [ + 'action' => 'edit', + 'id' => $id, + 'did_action' => 'regenerate', + ] + ) + ); exit; } diff --git a/inc/admin/profile/namespace.php b/inc/admin/profile/namespace.php index 61a2bbb..85d1a16 100644 --- a/inc/admin/profile/namespace.php +++ b/inc/admin/profile/namespace.php @@ -1,6 +1,9 @@ get_client(); - }); + $tokens = array_filter( + $tokens, + function ( Access_Token $token ) { + return (bool) $token->get_client(); + } + ); if ( ! IS_PROFILE_PAGE ) { $personal_url = PersonalTokens\get_page_url( [ 'user_id' => $user->ID ] ); @@ -40,7 +46,7 @@ function render_profile_section( WP_User $user ) { } ?> - +- - - - | -|
+ + + + | +
' . __( 'Token revoked.', 'oauth2' ) . '
' . esc_html__( 'Token revoked.', 'oauth2' ) . '
' . __( 'Unable to revoke token.', 'oauth2' ) . '
' . esc_html__( 'Unable to revoke token.', 'oauth2' ) . '
' . esc_html( $error->get_error_message() ) . '
'; - } ); + add_action( + 'all_admin_notices', + function () use ( $error ) { + echo '' . esc_html( $error->get_error_message() ) . '
' . __( 'Howdy %1$s,
"%2$s" would like to connect to %3$s.', 'oauth2' ) . '
- - + +