/**
  * Show a form where users can enter their license key
  * Takes Multisites into account
  *
  * @param bool $embedded
  * @return null
  */
 public function show_license_form($embedded = true)
 {
     // For non-multisites, always show the license form
     if (!is_multisite()) {
         parent::show_license_form($embedded);
         return;
     }
     // Plugin is network activated
     if ($this->is_network_activated) {
         // We're on the network admin
         if (is_network_admin()) {
             parent::show_license_form($embedded);
         } else {
             // We're not in the network admin area, show a notice
             parent::show_license_form_heading();
             if (is_super_admin()) {
                 echo "<p>" . sprintf(__('%s is network activated, you can manage your license in the <a href="%s">network admin license page</a>.', $this->product->get_text_domain()), $this->product->get_item_name(), $this->product->get_license_page_url()) . "</p>";
             } else {
                 echo "<p>" . sprintf(__('%s is network activated, please contact your site administrator to manage the license.', $this->product->get_text_domain()), $this->product->get_item_name()) . "</p>";
             }
         }
     } else {
         if (false == is_network_admin()) {
             parent::show_license_form($embedded);
         }
     }
 }
 /**
  * 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 MI_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()
 {
     $this->product = new MI_Product_Double();
     parent::__construct($this->product);
 }