Fragen\GitHub_Updater\Bitbucket_API::maybe_authenticate_http PHP Method

maybe_authenticate_http() public method

Add Basic Authentication $args to http_request_args filter hook for private Bitbucket repositories only.
public maybe_authenticate_http ( $args, $url ) : mixed
$args
$url
return mixed $args
    public function maybe_authenticate_http($args, $url)
    {
        if (!isset($this->type) || false === stristr($url, 'bitbucket')) {
            return $args;
        }
        $bitbucket_private = false;
        $bitbucket_private_install = false;
        /*
         * Check whether attempting to update private Bitbucket repo.
         */
        if (isset($this->type->repo) && !empty(parent::$options[$this->type->repo]) && false !== strpos($url, $this->type->repo)) {
            $bitbucket_private = true;
        }
        /*
         * Check whether attempting to install private Bitbucket repo
         * and abort if Bitbucket user/pass not set.
         */
        if (isset($_POST['option_page'], $_POST['is_private']) && 'github_updater_install' === $_POST['option_page'] && 'bitbucket' === $_POST['github_updater_api'] && (!empty(parent::$options['bitbucket_username']) || !empty(parent::$options['bitbucket_password']))) {
            $bitbucket_private_install = true;
        }
        if ($bitbucket_private || $bitbucket_private_install) {
            $username = parent::$options['bitbucket_username'];
            $password = parent::$options['bitbucket_password'];
            $args['headers']['Authorization'] = 'Basic ' . base64_encode("{$username}:{$password}");
        }
        return $args;
    }