plugin = WPFunctions::get()->pluginBasename($plugin_name); $this->slug = $slug; $this->version = $version; $this->settings = new SettingsController(); } function init() { WPFunctions::get()->addFilter('pre_set_site_transient_update_plugins', array($this, 'checkForUpdate')); } function checkForUpdate($update_transient) { if (!is_object($update_transient)) { $update_transient = new \stdClass; } $latest_version = $this->getLatestVersion(); if (isset($latest_version->new_version)) { if (version_compare($this->version, $latest_version->new_version, '<')) { $update_transient->response[$this->plugin] = $latest_version; } $update_transient->last_checked = time(); $update_transient->checked[$this->plugin] = $this->version; } return $update_transient; } function getLatestVersion() { $key = $this->settings->get(Bridge::PREMIUM_KEY_SETTING_NAME); $api = new API($key); $data = $api->getPluginInformation($this->slug . '/latest'); return $data; } }