diff --git a/lib/convertkit-api.php b/lib/convertkit-api.php index f2db93806..84f99e03a 100644 --- a/lib/convertkit-api.php +++ b/lib/convertkit-api.php @@ -33,7 +33,7 @@ public function get_resources($resource) { if(!array_key_exists($resource, $this->resources)) { $api_response = $this->_get_api_response($resource); - if (is_wp_error($api_response) || isset($api_response['error']) || isset($api_response['error_message'])) { + if (is_null($api_response) || is_wp_error($api_response) || isset($api_response['error']) || isset($api_response['error_message'])) { $this->resources[$resource] = array(); } else { $this->resources[$resource] = $api_response; @@ -82,7 +82,7 @@ public function get_resource($url) { if(!empty($url) && isset($this->markup[$url])) { $resource = $this->markup[$url]; } else if(!empty($url)) { - $response = wp_remote_get($url); + $response = wp_remote_get($url, array( 'timeout' => 2 )); if(!is_wp_error($response)) { if(!function_exists('str_get_html')) { @@ -128,7 +128,7 @@ private function _get_api_response($path = '') { $args = array('k' => $this->api_key, 'v' => $this->api_version); $url = add_query_arg($args, path_join($this->api_url_base, $path)); - $response = wp_remote_get($url); + $response = wp_remote_get($url, array( 'timeout' => 2 )); if(is_wp_error($response)) { $data = $response;