예제 #1
0
/**
 * Set our token option on activation if an Eventbrite connection already exists in Keyring.
 */
function eventbrite_check_existing_token()
{
    // Bail if Keyring isn't activated.
    if (!class_exists('Keyring_SingleStore')) {
        return;
    }
    // Get any Eventbrite tokens we may already have.
    $tokens = Keyring_SingleStore::init()->get_tokens(array('service' => 'eventbrite'));
    // If we have one, just use the first.
    if (!empty($tokens[0])) {
        update_option('eventbrite_api_token', $tokens[0]->unique_id);
    }
}
 /**
  * Check if we have a valid user connection to Eventbrite.
  *
  * @return bool True if a valid user token exists, false otherwise.
  */
 public static function has_active_connection()
 {
     // Definitely no connection if Keyring isn't activated.
     if (!class_exists('Keyring_SingleStore')) {
         return false;
     }
     // Let's check for Eventbrite connections.
     $tokens = Keyring_SingleStore::init()->get_tokens(array('service' => 'eventbrite', 'user_id' => 0));
     if (!empty($tokens[0])) {
         return true;
     } else {
         return false;
     }
 }