"POST", "body" => $post_vars)); /**/ $response = wp_remote_request ($url, $args); /* Get remote request response. */ /**/ if ($return === "array" && !is_wp_error ($response) && is_array ($response)) { $r["code"] = (int)wp_remote_retrieve_response_code ($response); $r["message"] = wp_remote_retrieve_response_message ($response); /**/ $r["headers"] = array (); /* Creates an array of lowercase headers. */ foreach (array_keys ($r["o_headers"] = wp_remote_retrieve_headers ($response)) as $header) $r["headers"][strtolower ($header)] = $r["o_headers"][$header]; /**/ $r["body"] = wp_remote_retrieve_body ($response); $r["response"] = $response; } /**/ else if (!is_wp_error ($response) && is_array ($response)) $r = wp_remote_retrieve_body ($response); /**/ else /* Else the request has failed. */ $r = false; /* Request failed. */ /**/ if (!empty ($curl_disabled) && $curl_disabled === 1352) remove_filter ("use_curl_transport", "__return_false", 1352); /**/ return $r; /* The return value. */ } /**/ return false; /* Else return false. */ } /** * Filters the `WP_Http` response for additional gzinflate variations. * * @package s2Member\Utilities * @since 3.5 * * @attaches-to: ``add_filter("http_response");`` * * @param array $response An array of response details. * @return array of ``$response`` details, with possible body modifications. */ public static function _remote_gz_variations ($response = array ()) { if (!isset ($response["ws__gz_variations"]) && ($response["ws__gz_variations"] = 1)) { if (!empty ($response["headers"]["content-encoding"])) if (!empty ($response["body"]) && substr ($response["body"], 0, 2) === "\x78\x9c") if (($gz = @gzinflate (substr ($response["body"], 2)))) $response["body"] = $gz; } /**/ return $response; /* Return response. */ } /** * Filters content redirection status *( uses 302s for browsers )*. * * @package s2Member\Utilities * @since 3.5 * * @attaches-to: ``add_filter("ws_plugin__s2member_content_redirect_status");`` * * @param int|str $status A numeric redirection status code. * @return int|str A numeric status redirection code, possibly modified to a value of `302`. * * @see http://en.wikipedia.org/wiki/Web_browser_engine */ public static function redirect_browsers_using_302_status ($status = 301) { $engines = "msie|trident|gecko|webkit|presto|konqueror|playstation"; /**/ if ((int)$status === 301 && !empty ($_SERVER["HTTP_USER_AGENT"])) if (($is_browser = preg_match ("/(" . $engines . ")[\/ ]([0-9\.]+)/i", $_SERVER["HTTP_USER_AGENT"]))) return 302; /**/ return $status; /* Else keep existing status code. */ } /** * Parses out a full valid URI, from either a full URL, or a partial. * * @package s2Member\Utilities * @since 3.5 * * @param str $url_or_uri Either a full URL, or a partial URI. * @return str|bool A valid URI, starting with `/` on success, else false. */ public static function parse_uri ($url_or_uri = FALSE) { if (($parse = @parse_url ($url_or_uri))) /* See: http://php.net/manual/en/function.parse-url.php. */ { $parse["path"] = (!empty ($parse["path"])) ? ((strpos ($parse["path"], "/") === 0) ? $parse["path"] : "/" . $parse["path"]) : "/"; $parse["path"] = preg_replace ("/\/+/", "/", $parse["path"]); /* Removes multi slashes. */ /**/ return (!empty ($parse["query"])) ? $parse["path"] . "?" . $parse["query"] : $parse["path"]; } /**/ return false; } } } ?>