private function get_github_release_asset_url()
{
$response = isset($this->response['release_asset_url']) ? $this->response['release_asset_url'] : false;
if ($this->exit_no_update($response)) {
return false;
}
if (!$response) {
$response = $this->api('/repos/:owner/:repo/releases/latest');
if (!$response) {
$response = new \stdClass();
$response->message = 'No release asset found';
}
if ($response) {
add_filter('http_request_args', array(&$this, 'set_github_release_asset_header'));
$url = $this->add_access_token_endpoint($this, $response->assets[0]->url);
$response_new = wp_remote_get($url);
remove_filter('http_request_args', array(&$this, 'set_github_release_asset_header'));
if (is_wp_error($response_new)) {
Messages::instance()->create_error_message($response_new);
return false;
}
if ($response_new['http_response'] instanceof \WP_HTTP_Requests_Response) {
$response_object = $response_new['http_response']->get_response_object();
$response_headers = $response_object->history[0]->headers;
$download_link = $response_headers->getValues('location');
} else {
return false;
}
$response = array();
$response = $download_link[0];
$this->set_transient('release_asset_url', $response);
}
}
if ($this->validate_response($response)) {
return false;
}
return $response;
}