Beispiel #1
0
 /**
  * Update transient for rollback or branch switch.
  *
  * @param string $type plugin|theme
  * @param object $repo
  */
 private function set_rollback_transient($type, $repo)
 {
     switch ($repo->type) {
         case 'github_plugin':
         case 'github_theme':
             $this->repo_api = new GitHub_API($repo);
             break;
         case 'bitbucket_plugin':
         case 'bitbucket_theme':
             $this->repo_api = new Bitbucket_API($repo);
             break;
         case 'gitlab_plugin':
         case 'gitlab_theme':
             $this->repo_api = new GitLab_API($repo);
             break;
     }
     $transient = 'update_' . $type . 's';
     $this->tag = $_GET['rollback'];
     $slug = 'plugin' === $type ? $repo->slug : $repo->repo;
     $updates_transient = get_site_transient($transient);
     $rollback = array($type => $slug, 'new_version' => $this->tag, 'url' => $repo->uri, 'package' => $this->repo_api->construct_download_link(false, $this->tag), 'branch' => $repo->branch, 'branches' => $repo->branches);
     if ('plugin' === $type) {
         $rollback['slug'] = $repo->repo;
         $updates_transient->response[$slug] = (object) $rollback;
     }
     if ('theme' === $type) {
         $updates_transient->response[$slug] = (array) $rollback;
     }
     set_site_transient($transient, $updates_transient);
 }
Beispiel #2
0
 /**
  * Get remote repo meta data for plugins or themes.
  * Calls remote APIs for data.
  *
  * @param $repo
  *
  * @return bool
  */
 public function get_remote_repo_meta($repo)
 {
     $this->repo_api = null;
     $file = 'style.css';
     if (false !== stristr($repo->type, 'plugin')) {
         $file = basename($repo->slug);
     }
     switch ($repo->type) {
         case 'github_plugin':
         case 'github_theme':
             $this->repo_api = new GitHub_API($repo);
             break;
         case 'bitbucket_plugin':
         case 'bitbucket_theme':
             $this->repo_api = new Bitbucket_API($repo);
             break;
         case 'gitlab_plugin':
         case 'gitlab_theme':
             $this->repo_api = new GitLab_API($repo);
             break;
     }
     if (null === $this->repo_api) {
         return false;
     }
     $this->{$repo->type} = $repo;
     $this->set_defaults($repo->type);
     if ($this->repo_api->get_remote_info($file)) {
         $this->repo_api->get_repo_meta();
         $this->repo_api->get_remote_tag();
         $changelog = $this->get_changelog_filename($repo->type);
         if ($changelog) {
             $this->repo_api->get_remote_changes($changelog);
         }
         $this->repo_api->get_remote_readme();
         $this->repo_api->get_remote_branches();
         $repo->download_link = $this->repo_api->construct_download_link();
     }
     return true;
 }