protected function api($url)
{
add_filter('http_request_args', array(&$this, 'http_request_args'), 10, 2);
$type = $this->return_repo_type();
$response = wp_remote_get($this->get_api_url($url));
$code = (int) wp_remote_retrieve_response_code($response);
$allowed_codes = array(200, 404);
if (is_wp_error($response)) {
Messages::instance()->create_error_message($response);
return false;
}
if (!in_array($code, $allowed_codes, false)) {
self::$error_code = array_merge(self::$error_code, array($this->type->repo => array('repo' => $this->type->repo, 'code' => $code, 'name' => $this->type->name, 'git' => $this->type->type)));
if ('github' === $type['repo']) {
GitHub_API::ratelimit_reset($response, $this->type->repo);
}
Messages::instance()->create_error_message($type['repo']);
return false;
}
return json_decode(wp_remote_retrieve_body($response));
}