Skip to content

Commit

Permalink
Add method to increment the app password count - see #30
Browse files Browse the repository at this point in the history
  • Loading branch information
julien731 committed Oct 11, 2016
1 parent 9194c71 commit e1f274a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions includes/class-recovery-key.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,33 @@ public function delete_key( $id ) {

}

/**
* Increment the use count for a key
*
* @since 1.2
*
* @param int $key_id ID of the key to increment
*
* @return false|int New count
*/
public function increment_count( $key_id ) {

global $wpdb;

$key = $this->get_key_by( 'ID', $key_id );

if ( empty( $key ) ) {
return false;
}

$count = (int) $key[0]['count'];
$count++;
$update = $wpdb->update( wpga_recovery_keys_table, array( 'count' => $count ), array( 'ID' => $key_id ), array( '%s' ), array( '%s' ) );

return false === $update ? false : $count;

}

/**
* Run a query on the recovery keys table
*
Expand Down

0 comments on commit e1f274a

Please sign in to comment.