/**
  * @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;
 }
 /**
  * @param iPlugin $plugin
  * @param         $response
  *
  * @return mixed
  */
 protected function format_response(iPlugin $plugin, $response)
 {
     $response->new_version = $response->version;
     $response->slug = dirname($plugin->slug());
     $response->plugin = $plugin->slug();
     // load license
     $this->license->load();
     // add some notices if license is inactive
     if (!$this->license->activated) {
         $response->upgrade_notice = sprintf('You will need to <a href="%s">activate your license</a> to install this plugin update.', admin_url('edit.php?post_type=scroll-triggered-box&page=stb-settings'));
         $response->sections->changelog = '<p>' . sprintf('You will need to <a href="%s" target="_top">activate your license</a> to install this plugin update.', admin_url('edit.php?post_type=scroll-triggered-box&page=stb-settings')) . '</p>' . $response->sections->changelog;
         $response->package = null;
     }
     // cast subkey objects to array as that is what WP expects
     $response->sections = get_object_vars($response->sections);
     $response->banners = get_object_vars($response->banners);
     return $response;
 }