/**
  * Append a warning message when a license is detected to be hosted on the legacy marvinlabs shop
  *
  * @param CUAR_LicenseStore $store The store where plugins are bought
  * @param string $message The original message
  * @param boolean $is_new_store_license true if the license is hosted on the new wpca shop
  * @return string The updated message
  */
 protected static function maybe_append_legacy_store_warning($store, $message, $is_new_store_license)
 {
     if ($is_new_store_license) {
         return $message;
     }
     return $message . '<br/>' . '<em class="cuar-old-shop-warning">' . sprintf(__('You have bought your license on the previous shop. We have a <a href="%1$s">brand new website</a>, please contact us so that we can help you migrate your license to the new shop.', 'cuar'), $store->get_store_url()) . '</em>';
 }
Ejemplo n.º 2
0
 /**
  * @param string $license
  * @param CUAR_AddOn $addon
  * @param boolean $use_new_store
  * @return array|mixed|null
  */
 private function query_store($license, $addon, $use_new_store)
 {
     // data to send in our API request
     $api_params = array('edd_action' => 'activate_license', 'license' => $license, 'url' => get_home_url());
     if ($use_new_store) {
         $store_url = $this->store->get_store_url();
         $api_params['item_id'] = (int) $addon->store_item_id;
     } else {
         $store_url = $this->store->get_legacy_store_url();
         if (false === $store_url) {
             return null;
         }
         $api_params['item_name'] = urlencode($addon->store_item_name);
     }
     // Call the custom API.
     $response = wp_remote_get(add_query_arg($api_params, $store_url), array('timeout' => 15, 'sslverify' => false));
     // make sure the response came back okay
     if (is_wp_error($response)) {
         return null;
     }
     $response = wp_remote_retrieve_body($response);
     $license_data = json_decode($response);
     // If not a valid license and license is missing, return null
     if (!isset($license_data) || $license_data->license != 'valid' && $license_data->error == 'missing') {
         return null;
     }
     return $license_data;
 }