/** * Make API request * * @param string $url * @return string */ function _request($url) { $request_url = Util_Environment::url_format(W3TC_PAGESPEED_API_URL, array('url' => $url, 'key' => $this->key)); $response = Util_Http::get($request_url, array('timeout' => 120)); if (!is_wp_error($response) && $response['response']['code'] == 200) { return $response['body']; } return false; }
/** * Redirects to URL * * @param string $url * @param array $params * * @return string */ public static function redirect_temp($url = '', $params = array()) { $url = Util_Environment::url_format($url, $params); if (function_exists('do_action')) { do_action('w3tc_redirect'); } $status_code = 301; $protocol = $_SERVER["SERVER_PROTOCOL"]; if ('HTTP/1.1' === $protocol) { $status_code = 307; } $text = get_status_header_desc($status_code); if (!empty($text)) { $status_header = "{$protocol} {$status_code} {$text}"; @header($status_header, true, $status_code); } @header('Cache-Control: no-cache'); @header('Location: ' . $url, true, $status_code); exit; }