public function has_valid_license($flush = false)
 {
     if (!$flush) {
         $has_valid_license = get_transient('gwp_has_valid_license');
         if ($has_valid_license !== false) {
             return $has_valid_license == true;
         }
     }
     $license = GWPerks::get_license_key();
     // 'check_license' is a standard EDD API action
     $api_params = self::get_api_args(array('edd_action' => 'check_license', 'license' => $license, 'item_name' => urlencode($this->get_product_name())));
     $request_url = esc_url_raw(add_query_arg($api_params, GW_STORE_URL));
     $response = wp_remote_get($request_url, self::get_request_args());
     if (GravityPerks::is_debug()) {
         print_rr(array('request_url' => $request_url, 'response' => $response, '_SERVER' => $_SERVER));
     }
     if (is_wp_error($response)) {
         return false;
     }
     $license_data = json_decode(wp_remote_retrieve_body($response));
     if (is_object($license_data)) {
         // at some point EDD added 'site_inactive' status which indicates the license has not been activated for this
         // site even though it already might have been, go ahead and activate it and see if it is still active
         if (in_array($license_data->license, array('inactive', 'site_inactive'))) {
             $has_valid_license = $this->activate_license($license);
         } else {
             $has_valid_license = $license_data->license == 'valid';
         }
     } else {
         $has_valid_license = false;
     }
     set_transient('gwp_has_valid_license', $has_valid_license ? 1 : 0, 60 * 60 * 24);
     // cache license daily
     return $has_valid_license;
 }
Example #2
0
 function drop_tables($tables)
 {
     GravityPerks::drop_tables($tables);
 }
 public static function store_modified_form($form)
 {
     self::$form = $form;
     return $form;
 }