public function construct_download_link($rollback = false, $branch_switch = false)
{
$download_link_base = implode('/', array('https://bitbucket.org', $this->type->owner, $this->type->repo, 'get/'));
$endpoint = '';
if ($this->type->release_asset && '0.0.0' !== $this->type->newest_tag) {
return $this->make_release_asset_download_link();
}
/*
* Check for rollback.
*/
if (!empty($_GET['rollback']) && (isset($_GET['action']) && 'upgrade-theme' === $_GET['action']) && (isset($_GET['theme']) && $this->type->repo === $_GET['theme'])) {
$endpoint .= $rollback . '.zip';
// for users wanting to update against branch other than master or not using tags, else use newest_tag
} elseif ('master' != $this->type->branch || empty($this->type->tags)) {
$endpoint .= $this->type->branch . '.zip';
} else {
$endpoint .= $this->type->newest_tag . '.zip';
}
/*
* Create endpoint for branch switching.
*/
if ($branch_switch) {
$endpoint = $branch_switch . '.zip';
}
return $download_link_base . $endpoint;
}