Ejemplo n.º 1
0
 /**
  * Gets the remote product data from a 3-hour transient
  *
  * @return bool|mixed
  */
 private function get_cached_remote_data()
 {
     $data = get_transient($this->product->get_slug() . 'update-response');
     if ($data) {
         return $data;
     }
     return false;
 }
Ejemplo n.º 2
0
 /**
  * Calls the API and, if successfull, returns the object delivered by the API.
  *
  * @uses         get_bloginfo()
  * @uses         wp_remote_post()
  * @uses         is_wp_error()
  *
  * @return false||object
  */
 protected function call_remote_api()
 {
     // only check if a transient is not set (or if it's expired)
     if (get_transient($this->product->get_slug() . '-update-check-error') !== false) {
         return;
     }
     // setup api parameters
     $api_params = array('edd_action' => 'get_version', 'license' => $this->license_key, 'name' => $this->product->get_item_name(), 'slug' => $this->product->get_slug(), 'author' => $this->product->get_author());
     // setup request parameters
     $request_params = array('timeout' => 15, 'sslverify' => false, 'body' => $api_params);
     // call remote api
     $response = wp_remote_post($this->product->get_api_url(), $request_params);
     // wp / http error?
     if (is_wp_error($response)) {
         $this->wp_error = $response;
         // show error to user
         add_action('admin_notices', array($this, 'show_update_error'));
         // set a transient to prevent checking for updates on every page load
         set_transient($this->product->get_slug() . '-update-check-error', true, 60 * 30);
         // 30 mins
         return false;
     }
     // decode response
     $response = json_decode(wp_remote_retrieve_body($response));
     $response->sections = maybe_unserialize($response->sections);
     return $response;
 }
Ejemplo n.º 3
0
 /**
  * Calls the API and, if successfull, returns the object delivered by the API.
  *
  * @uses         get_bloginfo()
  * @uses         wp_remote_post()
  * @uses         is_wp_error()
  *
  * @return false||object
  */
 protected function call_remote_api()
 {
     // only check if a transient is not set (or if it's expired)
     if (get_transient($this->product->get_slug() . '-update-check-error') !== false) {
         return false;
     }
     // setup api parameters
     $api_params = array('edd_action' => 'get_version', 'license' => $this->license_key, 'name' => $this->product->get_item_name(), 'slug' => $this->product->get_slug(), 'author' => $this->product->get_author());
     // setup request parameters
     $request_params = array('method' => 'POST', 'body' => $api_params);
     require_once dirname(__FILE__) . '/class-api-request.php';
     $request = new Yoast_API_Request($this->product->get_api_url(), $request_params);
     if ($request->is_valid() !== true) {
         // show error message
         $this->error_message = $request->get_error_message();
         add_action('admin_notices', array($this, 'show_update_error'));
         // set a transient to prevent checking for updates on every page load
         set_transient($this->product->get_slug() . '-update-check-error', 1, DAY_IN_SECONDS);
         // 30 mins
         return false;
     }
     // decode response
     $response = $request->get_response();
     $response->sections = maybe_unserialize($response->sections);
     return $response;
 }
Ejemplo n.º 4
0
 /**
  * Calls the API and, if successfull, returns the object delivered by the API.
  *
  * @uses         get_bloginfo()
  * @uses         wp_remote_post()
  * @uses         is_wp_error()
  *
  * @return false||object
  */
 private function call_remote_api()
 {
     // only check if the failed transient is not set (or if it's expired)
     if (get_transient($this->request_failed_transient_key) !== false) {
         return false;
     }
     // start request process
     global $wp_version;
     // set a transient to prevent failed update checks on every page load
     // this transient will be removed if a request succeeds
     set_transient($this->request_failed_transient_key, 'failed', 10800);
     // setup api parameters
     $api_params = array('edd_action' => 'get_version', 'license' => $this->license_manager->get_license_key(), 'item_name' => $this->product->get_item_name(), 'wp_version' => $wp_version, 'item_version' => $this->product->get_version(), 'url' => home_url(), 'slug' => $this->product->get_slug());
     // Add product ID from product if it is implemented.
     if (method_exists($this->product, 'get_product_id')) {
         $product_id = $this->product->get_product_id();
         if ($product_id > 0) {
             $api_params['product_id'] = $this->product->get_product_id();
         }
     }
     // setup request parameters
     $request_params = array('method' => 'POST', 'body' => $api_params);
     require_once dirname(__FILE__) . '/class-api-request.php';
     $request = new Yoast_API_Request($this->product->get_api_url(), $request_params);
     if ($request->is_valid() !== true) {
         // show error message
         $this->error_message = $request->get_error_message();
         add_action('admin_notices', array($this, 'show_update_error'));
         return false;
     }
     // request succeeded, delete transient indicating a request failed
     delete_transient($this->request_failed_transient_key);
     // decode response
     $response = $request->get_response();
     // check if response returned that a given site was inactive
     if (isset($response->license_check) && !empty($response->license_check) && $response->license_check != 'valid') {
         // deactivate local license
         $this->license_manager->set_license_status('invalid');
         // show notice to let the user know we deactivated his/her license
         $this->error_message = __("This site has not been activated properly on yoast.com and thus cannot check for future updates. Please activate your site with a valid license key.", $this->product->get_text_domain());
         add_action('admin_notices', array($this, 'show_update_error'));
     }
     $response->sections = maybe_unserialize($response->sections);
     // store response
     set_transient($this->response_transient_key, $response, 10800);
     return $response;
 }
 public function __construct()
 {
     parent::__construct('https://yoast.com', 'WooCommerce Yoast SEO', plugin_basename(Yoast_WooCommerce_SEO::get_plugin_file()), Yoast_WooCommerce_SEO::VERSION, 'https://yoast.com/wordpress/plugins/yoast-woocommerce-seo/', 'admin.php?page=wpseo_licenses#top#licenses', 'yoast-woo-seo', 'Yoast');
 }
 /**
  * Construct the real Product class with our fake data
  */
 public function __construct()
 {
     parent::__construct(get_site_url(), 'test-product', 'slug-test-product', '1.0.0');
 }
Ejemplo n.º 7
0
 public function __construct()
 {
     parent::__construct('https://yoast.com/edd-sl-api', 'News SEO', plugin_basename(WPSEO_News::get_file()), WPSEO_News::VERSION, 'https://yoast.com/wordpress/plugins/news-seo/', 'admin.php?page=wpseo_licenses#top#licenses', 'wordpress-seo-news', 'Yoast');
 }
Ejemplo n.º 8
0
 public function __construct()
 {
     parent::__construct('https://yoast.com/edd-sl-api', 'Local SEO for WordPress', plugin_basename(WPSEO_LOCAL_FILE), WPSEO_LOCAL_VERSION, 'https://yoast.com/wordpress/plugins/local-seo/', 'admin.php?page=wpseo_licenses#top#licenses', 'yoast-local-seo', 'Yoast');
 }
Ejemplo n.º 9
0
 public function __construct()
 {
     parent::__construct('https://yoast.com', 'Sample Product', 'sample-product', '1.0', 'https://yoast.com/wordpress/plugins/sample-product/', 'admin.php?page=sample-product', 'sample-product', 'Yoast');
 }
Ejemplo n.º 10
0
 /**
  * Set up the WPSEO_Video product
  */
 public function __construct()
 {
     parent::__construct('https://yoast.com/edd-sl-api', 'Video SEO for WordPress', plugin_basename(WPSEO_Video_Sitemap::get_plugin_file()), WPSEO_VIDEO_VERSION, 'https://yoast.com/wordpress/plugins/video-seo/', 'admin.php?page=wpseo_licenses#top#licenses', 'yoast-video-seo', 'Yoast');
 }
 public function __construct()
 {
     parent::__construct(SP_Constants::EDD_STORE_URL, SP_Constants::EDD_PLUGIN_NAME, plugin_basename(Post_Connector::get_plugin_file()), SP_Constants::PLUGIN_VERSION_NAME, 'https://www.post-connector.com/', 'admin.php?page=post_connector_license', 'post-connector', SP_Constants::PLUGIN_AUTHOR);
 }
 /**
  * Constructor of the class
  */
 public function __construct()
 {
     parent::__construct('https://yoast.com', 'Google Analytics by Yoast Premium', plugin_basename(GAWP_FILE), GA_YOAST_PREMIUM_VERSION, 'https://yoast.com/wordpress/plugins/google-analytics/', 'admin.php?page=yst_ga_extensions#top#licenses', 'yoast-google-analytics-premium', 'Yoast');
     $this->setup_license_manager();
 }
Ejemplo n.º 13
0
 public function __construct()
 {
     parent::__construct(trailingslashit(WPSEO_Premium::EDD_STORE_URL) . 'edd-sl-api', WPSEO_Premium::EDD_PLUGIN_NAME, plugin_basename(WPSEO_FILE), WPSEO_Premium::PLUGIN_VERSION_NAME, 'https://yoast.com/wordpress/plugins/seo-premium/', 'admin.php?page=wpseo_licenses#top#licenses', 'wordpress-seo', WPSEO_Premium::PLUGIN_AUTHOR);
 }