Fragen\GitHub_Updater\GitLab_API::construct_download_link PHP Метод

    public function construct_download_link($rollback = false, $branch_switch = false)
    {
        /*
         * Check if using GitLab CE/Enterprise.
         */
        if (!empty($this->type->enterprise)) {
            $gitlab_base = $this->type->enterprise;
        } else {
            $gitlab_base = 'https://gitlab.com';
        }
        $download_link_base = implode('/', array($gitlab_base, $this->type->owner, $this->type->repo, 'repository/archive.zip'));
        $endpoint = '';
        /*
         * If release asset.
         */
        if ($this->type->release_asset && '0.0.0' !== $this->type->newest_tag) {
            $download_link_base = $this->make_release_asset_download_link();
            return $this->add_access_token_endpoint($this, $download_link_base);
        }
        /*
         * If a branch has been given, only check that for the remote info.
         * If branch is master (default) and tags are used, use newest tag.
         */
        if ('master' === $this->type->branch && !empty($this->type->tags)) {
            $endpoint = remove_query_arg('ref', $endpoint);
            $endpoint = add_query_arg('ref', $this->type->newest_tag, $endpoint);
        } elseif (!empty($this->type->branch)) {
            $endpoint = remove_query_arg('ref', $endpoint);
            $endpoint = add_query_arg('ref', $this->type->branch, $endpoint);
        }
        /*
         * Check for rollback.
         */
        if (!empty($_GET['rollback']) && (isset($_GET['action']) && 'upgrade-theme' === $_GET['action']) && (isset($_GET['theme']) && $this->type->repo === $_GET['theme'])) {
            $endpoint = remove_query_arg('ref', $endpoint);
            $endpoint = add_query_arg('ref', esc_attr($_GET['rollback']), $endpoint);
        }
        /*
         * Create endpoint for branch switching.
         */
        if ($branch_switch) {
            $endpoint = remove_query_arg('ref', $endpoint);
            $endpoint = add_query_arg('ref', $branch_switch, $endpoint);
        }
        $endpoint = $this->add_access_token_endpoint($this, $endpoint);
        return $download_link_base . $endpoint;
    }