/**
  * Delete transient.
  *
  * @since  1.0.0
  */
 public function delete()
 {
     do_action('ms_model_transient_delete_before', $this);
     $option_key = $this->option_key();
     MS_Factory::delete_transient($option_key);
     wp_cache_delete($option_key, 'MS_Model_Transient');
     do_action('ms_model_transient_delete_after', $this);
 }
 /**
  * Remove user application for this coupon.
  *
  * @since  1.0.0
  *
  * @param int $user_id The user id.
  * @param int $membership_id The membership id.
  */
 public static function remove_application($user_id, $membership_id)
 {
     $key = self::get_transient_name($user->id, $membership->id);
     MS_Factory::delete_transient($key);
     do_action('ms_addon_coupon_model_remove_application', $user_id, $membership_id);
 }
 /**
  * Verfies the admin token in the $_GET collection
  *
  * $_GET['ms_token'] must match the current ms_token
  * $_POST['confirm'] must have value 'yes'
  *
  * @since  1.0.0
  * @internal
  *
  * @param  string $action Like a nonce, this is the action to execute.
  * @return bool
  */
 private static function verify_token($action)
 {
     if (!self::valid_user()) {
         return false;
     }
     if (empty($_GET['ms_token'])) {
         return false;
     }
     $get_token = $_GET['ms_token'];
     if (empty($_POST['confirm'])) {
         return false;
     }
     if ('yes' != $_POST['confirm']) {
         return false;
     }
     $one_time_key = MS_Factory::get_transient('ms_one_time_key-' . $action);
     MS_Factory::delete_transient('ms_one_time_key-' . $action);
     if (empty($one_time_key)) {
         return false;
     }
     // We verify the current and the previous beat
     $plain_token_1 = $action . '-' . date('B') . ':' . get_current_user_id() . '-' . $one_time_key;
     $plain_token_2 = $action . '-' . (date('B') - 1) . ':' . get_current_user_id() . '-' . $one_time_key;
     if (wp_verify_nonce($get_token, $plain_token_1)) {
         return true;
     }
     if (wp_verify_nonce($get_token, $plain_token_2)) {
         return true;
     }
     return false;
 }
 /**
  * Remove user application for this invitation.
  *
  * @since  1.0.0
  *
  * @param int $user_id The user id.
  * @param int $membership_id The membership id.
  */
 public function remove_application($user_id, $membership_id)
 {
     $key = self::get_transient_name($user_id, $membership_id);
     MS_Factory::delete_transient($key);
     $this->remove_invitation_check();
     do_action('ms_addon_invitation_model_remove_application', $user_id, $membership_id, $this);
 }