private function verify()
 {
     if (!wskl_is_option_enabled('enable_sym_pg')) {
         return TRUE;
     }
     if (!is_null($this->verified) && is_bool($this->verified)) {
         return $this->verified;
     }
     $info = new WSKL_Auth_Info('payment');
     $key_type = $info->get_key_type();
     $key_value = $info->get_key_value();
     $site_url = site_url();
     // verification null 은 인증 실패. false 는 인증 서버 다운 등의 이유로 인증 시도가 이뤄지지 못함.
     $verification = ClientAPI::verify($key_type, $key_value, $site_url);
     if ($verification instanceof OrderItemRelation) {
         $info->set_oir($verification);
         $info->save();
         $this->verified = TRUE;
     } else {
         if ($verification === NULL) {
             // 인증 실패
             $this->verified = FALSE;
         } else {
             if ($verification === FALSE) {
                 // 인증 불가 (서버의 이상)
                 $this->verified = $info->is_verified();
             }
         }
     }
     return $this->verified;
 }
 private function send_sales_log($order_id)
 {
     $auth = new \WSKL_Auth_Info('marketing');
     if ($auth->is_verified()) {
         $key_type = $auth->get_key_type();
         $key_value = $auth->get_key_value();
         $user_id = $auth->get_oir()->get_user_id();
         $site_url = site_url();
         SalesAPI::send_data($key_type, $key_value, $site_url, $user_id, $order_id);
     }
 }
 public static function callback_woocommerce_before_single_product()
 {
     $auth = new \WSKL_Auth_Info('marketing');
     if ($auth->is_verified()) {
         $key_type = $auth->get_key_type();
         $key_value = $auth->get_key_value();
         $user_id = $auth->get_oir()->get_user_id();
         $site_url = site_url();
         $product_id = get_the_ID();
         TodaySeenAPI::send_data($key_type, $key_value, $site_url, $user_id, $product_id, 0, 0);
     }
 }
 public static function callback_save_post($post_id, \WP_Post $post, $update)
 {
     if (!$update || defined('DOING_AJAX') || defined('DOING_AUTOSAVE')) {
         return;
     }
     $is_export_allowed = filter_var($_POST['dabory-post-export'], FILTER_VALIDATE_BOOLEAN);
     if (!$is_export_allowed) {
         return;
     }
     $auth = new \WSKL_Auth_Info('marketing');
     if ($auth->is_verified()) {
         $key_type = $auth->get_key_type();
         $key_value = $auth->get_key_value();
         $user_id = $auth->get_oir()->get_user_id();
         $site_url = site_url();
         PostAPI::send_post($key_type, $key_value, $site_url, $user_id, $post_id);
         update_post_meta($post_id, LAST_POST_EXPORT, time());
     }
 }
 /**
  * @param $key_type
  * @param $echo
  *
  * @return string|void
  */
 public static function get_license_duration_string($key_type, $echo = FALSE)
 {
     $info = new WSKL_Auth_Info($key_type);
     if ($info->is_available()) {
         if ($info->is_verified()) {
             $days_left = $info->get_oir()->get_key()->get_days_left();
             $text = '<span class="wskl-info">' . sprintf('%s: %s, %s: %s, %s: %s %s', __('발급일', 'wskl'), static::to_date_string($info->get_oir()->get_key()->get_issue_date()), __('만료일', 'wskl'), static::to_date_string($info->get_oir()->get_key()->get_expire_date()), __('남은 기간', 'wskl'), $info->is_expired() ? __('만료됨', 'wskl') : $days_left, _n('일', '일', $days_left, 'wskl')) . '</span>';
         } else {
             $text = '<span class="wskl-notice">' . __('활성화키가 인증되지 않아 기능이 실행되지 않습니다.', 'wskl') . '</span>';
         }
     } else {
         if (empty($key_type)) {
             $text = __('키를 입력하지 않았습니다.', 'wskl');
         } else {
             $text = '<span class="wskl-notice">' . __('활성화키가 인증되지 않아 기능이 실행되지 않습니다.', 'wskl') . '</span>';
         }
     }
     if (!$echo) {
         return $text;
     }
     echo $text;
 }
 public static function callback_save_post($post_id, \WP_Post $post, $update)
 {
     if (!$update || defined('DOING_AJAX') || defined('DOING_AUTOSAVE')) {
         return;
     }
     $is_export_allowed = filter_var(wskl_POST('allow-export'), FILTER_VALIDATE_BOOLEAN);
     if (!$is_export_allowed) {
         return;
     }
     $auth = new WSKL_Auth_Info('marketing');
     if ($auth->is_verified()) {
         $key_type = $auth->get_key_type();
         $key_value = $auth->get_key_value();
         $user_id = $auth->get_oir()->get_user_id();
         $site_url = site_url();
         $remote_post_id = PostAPI::send_post($key_type, $key_value, $site_url, $user_id, $post_id);
         if ($remote_post_id) {
             $metadata = array('post_modified' => $post->post_modified, 'post_modified_gmt' => $post->post_modified_gmt, 'exported' => time(), 'remote_post_id' => $remote_post_id);
             update_post_meta($post_id, wskl_get_option_name('post_export_metadata'), $metadata);
         } else {
             error_log('callback_save_post() finished unsuccessfully!');
         }
     }
 }
function wskl_license_authorized($license_type)
{
    $info = new WSKL_Auth_Info($license_type);
    return $info->is_available() && $info->is_verified();
}