fix additional URLs

Former-commit-id: 764f12323d
This commit is contained in:
Leon 2017-03-16 21:41:25 +13:00
parent 67fb00af41
commit 0e2738a96a
3 changed files with 48 additions and 24 deletions

View file

@ -28,10 +28,21 @@ class StaticHtmlOutput_UrlRequest
*/
public function __construct($url, $cleanMeta = false)
{
$this->_url = filter_var($url, FILTER_VALIDATE_URL);
$this->_url = filter_var(trim($url), FILTER_VALIDATE_URL);
$this->_cleanMeta = $cleanMeta;
$response = wp_remote_get($this->_url,array('timeout'=>300)); //set a long time out
$this->_response = (is_wp_error($response) ? '' : $response);
$this->_response = '';
if (is_wp_error($response)) {
error_log('WP_ERROR');
error_log(print_r($response, true));
$this->_response = 'FAIL';
} else {
$this->_response = $response;
}
}
/**
@ -42,6 +53,11 @@ class StaticHtmlOutput_UrlRequest
{
return $this->_url;
}
public function checkResponse()
{
return $this->_response;
}
/**
* Allows to override the HTTP response body