/** * @return bool */ public function init() { // do nothing if not authenticated if (!current_user_can('manage_options')) { return false; } // load license $this->license->load(); // register license key form add_action('stb_after_settings', array($this, 'show_license_form')); // listen for activation / deactivation requests $this->listen(); // register update checks return true; }
/** * @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; }