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