/** * Adds meta links to the plugin in the WP Admin > Plugins screen * * @param array $links * @param string $slug * * @return array */ public function add_plugin_meta_links($links, $slug) { if ($slug !== $this->plugin->slug()) { return $links; } $links[] = '<a href="https://kb.boxzillaplugin.com/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Documentation</a>'; $links[] = '<a href="https://boxzillaplugin.com/add-ons/#utm_source=wp-plugin&utm_medium=boxzilla&utm_campaign=plugins-page">Add-ons</a>'; return $links; }
/** * @param Plugin $plugin * @param $response * * @return mixed */ protected function format_response(Plugin $plugin, $response) { $response->new_version = $response->version; $response->slug = dirname($plugin->slug()); $response->plugin = $plugin->slug(); // 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=boxzilla-box&page=boxzilla-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=boxzilla-box&page=boxzilla-settings')) . '</p>' . $response->sections->changelog; $response->package = null; } else { // add activation key to download URL $response->package = add_query_arg(array('key' => $this->license->activation_key), $response->package); } // 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; }
/** * @param Plugin $plugin * @return object */ public function get_plugin(Plugin $plugin) { $endpoint = sprintf('/plugins/%s?format=wp', $plugin->id()); $response = $this->request('GET', $endpoint); return $response; }