current_version = $current_version; $this->update_path = $update_path; $this->plugin_slug = $plugin_slug; $t = explode('/', $plugin_slug); $this->slug = str_replace('.php', '', $t[1]); // define the alternative API for updating checking add_filter('pre_set_site_transient_update_plugins', array(&$this, 'check_update')); // Define the alternative response for information checking add_filter('plugins_api', array(&$this, 'check_info'), 10, 3); } /** * Add our self-hosted autoupdate plugin to the filter transient * * @param $transient * @return object $ transient */ public function check_update($transient) { if (empty($transient->checked)) { return $transient; } // Get the remote version $remote_version = $this->getRemote_version(); // If a newer version is available, add the update if (version_compare($this->current_version, $remote_version, '<')) { $obj = new stdClass(); $obj->slug = $this->slug; $obj->new_version = $remote_version; $obj->url = ''; // $this->update_path; $obj->package = ''; // $this->update_path; $transient->response[$this->plugin_slug] = $obj; } return $transient; } /** * Add our self-hosted description to the filter * * @param boolean $false * @param array $action * @param object $arg * @return bool|object */ public function check_info($false, $action, $arg) { if (isset($arg->slug) && $arg->slug === $this->slug) { $information = $this->getRemote_information(); $array_pattern = array( '/^([\*\s])*(\d\d\.\d\d\.\d\d\d\d[^\n]*)/m', '/^\n+|^[\t\s]*\n+/m', '/\n/', ); $array_replace = array( '