/** * @return bool */ protected function listen() { // nothing to do if (!isset($_POST['stb_license_form'])) { return false; } $key_changed = false; // the form was submitted, let's see.. if ($_POST['action'] === 'deactivate') { $this->license->deactivate(); $this->api->logout(); } // did key change or was "activate" button pressed? $new_license_key = sanitize_text_field($_POST['license_key']); if ($new_license_key !== $this->license->key) { $this->license->key = $new_license_key; $key_changed = true; } if (!empty($new_license_key) && !$this->license->activated && ($_POST['action'] === 'activate' || $key_changed)) { // let's try to activate it if ($this->api->login()) { $this->license->activate(); } } $this->license->save(); return false; }
/** * Fetch array of available updates from remote server * * @return array */ protected function fetch_updates() { if (is_array($this->available_updates)) { return $this->available_updates; } // fetch remote info $remote_plugins = $this->api->get_plugins($this->extensions); // start with an empty array $this->available_updates = array(); // did we get a valid response? if (!is_array($remote_plugins)) { return $this->available_updates; } // filter remote plugins, we only want the ones with an update available $this->available_updates = $this->filter_remote_plugins($remote_plugins); return $this->available_updates; }