get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE 'oauth1_access_%'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery
$approved = array();
foreach ( $results as $option_name ) {
$option = get_option( $option_name );
if ( ! is_array( $option ) || ! isset( $option['user'] ) ) {
continue;
}
if ( $option['user'] === $user->ID ) {
$approved[] = $option;
}
}
?>
%s
', esc_html__( 'Token revoked.', 'rest_oauth1' ) );
}
if ( ! empty( $_GET['rest_oauth1_revocation_failed'] ) ) {
printf( '', esc_html__( 'Unable to revoke token.', 'rest_oauth1' ) );
}
}
/**
* REST oauth profile save callback.
*
* @param int $user_id User ID.
*/
function rest_oauth1_profile_save( $user_id ) {
if ( empty( $_POST['rest_oauth1_revoke'] ) ) {
return;
}
$key = wp_unslash( $_POST['rest_oauth1_revoke'] );
$authenticator = new WP_REST_OAuth1();
$result = $authenticator->revoke_access_token( $key );
if ( is_wp_error( $result ) ) {
$redirect = add_query_arg( 'rest_oauth1_revocation_failed', true, get_edit_user_link( $user_id ) );
} else {
$redirect = add_query_arg( 'rest_oauth1_revoked', $key, get_edit_user_link( $user_id ) );
}
wp_redirect( $redirect );
exit;
}