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);
}