Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: class-wp-http.php
[500] Fix | Delete
/**
[501] Fix | Delete
* Validate redirected URLs.
[502] Fix | Delete
*
[503] Fix | Delete
* @since 4.7.5
[504] Fix | Delete
*
[505] Fix | Delete
* @throws WpOrg\Requests\Exception On unsuccessful URL validation.
[506] Fix | Delete
* @param string $location URL to redirect to.
[507] Fix | Delete
*/
[508] Fix | Delete
public static function validate_redirects( $location ) {
[509] Fix | Delete
if ( ! wp_http_validate_url( $location ) ) {
[510] Fix | Delete
throw new WpOrg\Requests\Exception( __( 'A valid URL was not provided.' ), 'wp_http.redirect_failed_validation' );
[511] Fix | Delete
}
[512] Fix | Delete
}
[513] Fix | Delete
[514] Fix | Delete
/**
[515] Fix | Delete
* Tests which transports are capable of supporting the request.
[516] Fix | Delete
*
[517] Fix | Delete
* @since 3.2.0
[518] Fix | Delete
* @deprecated 6.4.0 Use WpOrg\Requests\Requests::get_transport_class()
[519] Fix | Delete
* @see WpOrg\Requests\Requests::get_transport_class()
[520] Fix | Delete
*
[521] Fix | Delete
* @param array $args Request arguments.
[522] Fix | Delete
* @param string $url URL to request.
[523] Fix | Delete
* @return string|false Class name for the first transport that claims to support the request.
[524] Fix | Delete
* False if no transport claims to support the request.
[525] Fix | Delete
*/
[526] Fix | Delete
public function _get_first_available_transport( $args, $url = null ) {
[527] Fix | Delete
$transports = array( 'curl', 'streams' );
[528] Fix | Delete
[529] Fix | Delete
/**
[530] Fix | Delete
* Filters which HTTP transports are available and in what order.
[531] Fix | Delete
*
[532] Fix | Delete
* @since 3.7.0
[533] Fix | Delete
* @deprecated 6.4.0 Use WpOrg\Requests\Requests::get_transport_class()
[534] Fix | Delete
*
[535] Fix | Delete
* @param string[] $transports Array of HTTP transports to check. Default array contains
[536] Fix | Delete
* 'curl' and 'streams', in that order.
[537] Fix | Delete
* @param array $args HTTP request arguments.
[538] Fix | Delete
* @param string $url The URL to request.
[539] Fix | Delete
*/
[540] Fix | Delete
$request_order = apply_filters_deprecated( 'http_api_transports', array( $transports, $args, $url ), '6.4.0' );
[541] Fix | Delete
[542] Fix | Delete
// Loop over each transport on each HTTP request looking for one which will serve this request's needs.
[543] Fix | Delete
foreach ( $request_order as $transport ) {
[544] Fix | Delete
if ( in_array( $transport, $transports, true ) ) {
[545] Fix | Delete
$transport = ucfirst( $transport );
[546] Fix | Delete
}
[547] Fix | Delete
$class = 'WP_Http_' . $transport;
[548] Fix | Delete
[549] Fix | Delete
// Check to see if this transport is a possibility, calls the transport statically.
[550] Fix | Delete
if ( ! call_user_func( array( $class, 'test' ), $args, $url ) ) {
[551] Fix | Delete
continue;
[552] Fix | Delete
}
[553] Fix | Delete
[554] Fix | Delete
return $class;
[555] Fix | Delete
}
[556] Fix | Delete
[557] Fix | Delete
return false;
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
/**
[561] Fix | Delete
* Dispatches a HTTP request to a supporting transport.
[562] Fix | Delete
*
[563] Fix | Delete
* Tests each transport in order to find a transport which matches the request arguments.
[564] Fix | Delete
* Also caches the transport instance to be used later.
[565] Fix | Delete
*
[566] Fix | Delete
* The order for requests is cURL, and then PHP Streams.
[567] Fix | Delete
*
[568] Fix | Delete
* @since 3.2.0
[569] Fix | Delete
* @deprecated 5.1.0 Use WP_Http::request()
[570] Fix | Delete
* @see WP_Http::request()
[571] Fix | Delete
*
[572] Fix | Delete
* @param string $url URL to request.
[573] Fix | Delete
* @param array $args Request arguments.
[574] Fix | Delete
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
[575] Fix | Delete
* A WP_Error instance upon error.
[576] Fix | Delete
*/
[577] Fix | Delete
private function _dispatch_request( $url, $args ) {
[578] Fix | Delete
static $transports = array();
[579] Fix | Delete
[580] Fix | Delete
$class = $this->_get_first_available_transport( $args, $url );
[581] Fix | Delete
if ( ! $class ) {
[582] Fix | Delete
return new WP_Error( 'http_failure', __( 'There are no HTTP transports available which can complete the requested request.' ) );
[583] Fix | Delete
}
[584] Fix | Delete
[585] Fix | Delete
// Transport claims to support request, instantiate it and give it a whirl.
[586] Fix | Delete
if ( empty( $transports[ $class ] ) ) {
[587] Fix | Delete
$transports[ $class ] = new $class();
[588] Fix | Delete
}
[589] Fix | Delete
[590] Fix | Delete
$response = $transports[ $class ]->request( $url, $args );
[591] Fix | Delete
[592] Fix | Delete
/** This action is documented in wp-includes/class-wp-http.php */
[593] Fix | Delete
do_action( 'http_api_debug', $response, 'response', $class, $args, $url );
[594] Fix | Delete
[595] Fix | Delete
if ( is_wp_error( $response ) ) {
[596] Fix | Delete
return $response;
[597] Fix | Delete
}
[598] Fix | Delete
[599] Fix | Delete
/** This filter is documented in wp-includes/class-wp-http.php */
[600] Fix | Delete
return apply_filters( 'http_response', $response, $args, $url );
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
/**
[604] Fix | Delete
* Uses the POST HTTP method.
[605] Fix | Delete
*
[606] Fix | Delete
* Used for sending data that is expected to be in the body.
[607] Fix | Delete
*
[608] Fix | Delete
* @since 2.7.0
[609] Fix | Delete
*
[610] Fix | Delete
* @param string $url The request URL.
[611] Fix | Delete
* @param string|array $args Optional. Override the defaults.
[612] Fix | Delete
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
[613] Fix | Delete
* A WP_Error instance upon error. See WP_Http::response() for details.
[614] Fix | Delete
*/
[615] Fix | Delete
public function post( $url, $args = array() ) {
[616] Fix | Delete
$defaults = array( 'method' => 'POST' );
[617] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[618] Fix | Delete
return $this->request( $url, $parsed_args );
[619] Fix | Delete
}
[620] Fix | Delete
[621] Fix | Delete
/**
[622] Fix | Delete
* Uses the GET HTTP method.
[623] Fix | Delete
*
[624] Fix | Delete
* Used for sending data that is expected to be in the body.
[625] Fix | Delete
*
[626] Fix | Delete
* @since 2.7.0
[627] Fix | Delete
*
[628] Fix | Delete
* @param string $url The request URL.
[629] Fix | Delete
* @param string|array $args Optional. Override the defaults.
[630] Fix | Delete
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
[631] Fix | Delete
* A WP_Error instance upon error. See WP_Http::response() for details.
[632] Fix | Delete
*/
[633] Fix | Delete
public function get( $url, $args = array() ) {
[634] Fix | Delete
$defaults = array( 'method' => 'GET' );
[635] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[636] Fix | Delete
return $this->request( $url, $parsed_args );
[637] Fix | Delete
}
[638] Fix | Delete
[639] Fix | Delete
/**
[640] Fix | Delete
* Uses the HEAD HTTP method.
[641] Fix | Delete
*
[642] Fix | Delete
* Used for sending data that is expected to be in the body.
[643] Fix | Delete
*
[644] Fix | Delete
* @since 2.7.0
[645] Fix | Delete
*
[646] Fix | Delete
* @param string $url The request URL.
[647] Fix | Delete
* @param string|array $args Optional. Override the defaults.
[648] Fix | Delete
* @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'.
[649] Fix | Delete
* A WP_Error instance upon error. See WP_Http::response() for details.
[650] Fix | Delete
*/
[651] Fix | Delete
public function head( $url, $args = array() ) {
[652] Fix | Delete
$defaults = array( 'method' => 'HEAD' );
[653] Fix | Delete
$parsed_args = wp_parse_args( $args, $defaults );
[654] Fix | Delete
return $this->request( $url, $parsed_args );
[655] Fix | Delete
}
[656] Fix | Delete
[657] Fix | Delete
/**
[658] Fix | Delete
* Parses the responses and splits the parts into headers and body.
[659] Fix | Delete
*
[660] Fix | Delete
* @since 2.7.0
[661] Fix | Delete
*
[662] Fix | Delete
* @param string $response The full response string.
[663] Fix | Delete
* @return array {
[664] Fix | Delete
* Array with response headers and body.
[665] Fix | Delete
*
[666] Fix | Delete
* @type string $headers HTTP response headers.
[667] Fix | Delete
* @type string $body HTTP response body.
[668] Fix | Delete
* }
[669] Fix | Delete
*/
[670] Fix | Delete
public static function processResponse( $response ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
[671] Fix | Delete
$response = explode( "\r\n\r\n", $response, 2 );
[672] Fix | Delete
[673] Fix | Delete
return array(
[674] Fix | Delete
'headers' => $response[0],
[675] Fix | Delete
'body' => isset( $response[1] ) ? $response[1] : '',
[676] Fix | Delete
);
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
/**
[680] Fix | Delete
* Transforms header string into an array.
[681] Fix | Delete
*
[682] Fix | Delete
* @since 2.7.0
[683] Fix | Delete
*
[684] Fix | Delete
* @param string|array $headers The original headers. If a string is passed, it will be converted
[685] Fix | Delete
* to an array. If an array is passed, then it is assumed to be
[686] Fix | Delete
* raw header data with numeric keys with the headers as the values.
[687] Fix | Delete
* No headers must be passed that were already processed.
[688] Fix | Delete
* @param string $url Optional. The URL that was requested. Default empty.
[689] Fix | Delete
* @return array {
[690] Fix | Delete
* Processed string headers. If duplicate headers are encountered,
[691] Fix | Delete
* then a numbered array is returned as the value of that header-key.
[692] Fix | Delete
*
[693] Fix | Delete
* @type array $response {
[694] Fix | Delete
* @type int $code The response status code. Default 0.
[695] Fix | Delete
* @type string $message The response message. Default empty.
[696] Fix | Delete
* }
[697] Fix | Delete
* @type array $newheaders The processed header data as a multidimensional array.
[698] Fix | Delete
* @type WP_Http_Cookie[] $cookies If the original headers contain the 'Set-Cookie' key,
[699] Fix | Delete
* an array containing `WP_Http_Cookie` objects is returned.
[700] Fix | Delete
* }
[701] Fix | Delete
*/
[702] Fix | Delete
public static function processHeaders( $headers, $url = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
[703] Fix | Delete
// Split headers, one per array element.
[704] Fix | Delete
if ( is_string( $headers ) ) {
[705] Fix | Delete
// Tolerate line terminator: CRLF = LF (RFC 2616 19.3).
[706] Fix | Delete
$headers = str_replace( "\r\n", "\n", $headers );
[707] Fix | Delete
/*
[708] Fix | Delete
* Unfold folded header fields. LWS = [CRLF] 1*( SP | HT ) <US-ASCII SP, space (32)>,
[709] Fix | Delete
* <US-ASCII HT, horizontal-tab (9)> (RFC 2616 2.2).
[710] Fix | Delete
*/
[711] Fix | Delete
$headers = preg_replace( '/\n[ \t]/', ' ', $headers );
[712] Fix | Delete
// Create the headers array.
[713] Fix | Delete
$headers = explode( "\n", $headers );
[714] Fix | Delete
}
[715] Fix | Delete
[716] Fix | Delete
$response = array(
[717] Fix | Delete
'code' => 0,
[718] Fix | Delete
'message' => '',
[719] Fix | Delete
);
[720] Fix | Delete
[721] Fix | Delete
/*
[722] Fix | Delete
* If a redirection has taken place, The headers for each page request may have been passed.
[723] Fix | Delete
* In this case, determine the final HTTP header and parse from there.
[724] Fix | Delete
*/
[725] Fix | Delete
for ( $i = count( $headers ) - 1; $i >= 0; $i-- ) {
[726] Fix | Delete
if ( ! empty( $headers[ $i ] ) && ! str_contains( $headers[ $i ], ':' ) ) {
[727] Fix | Delete
$headers = array_splice( $headers, $i );
[728] Fix | Delete
break;
[729] Fix | Delete
}
[730] Fix | Delete
}
[731] Fix | Delete
[732] Fix | Delete
$cookies = array();
[733] Fix | Delete
$newheaders = array();
[734] Fix | Delete
foreach ( (array) $headers as $tempheader ) {
[735] Fix | Delete
if ( empty( $tempheader ) ) {
[736] Fix | Delete
continue;
[737] Fix | Delete
}
[738] Fix | Delete
[739] Fix | Delete
if ( ! str_contains( $tempheader, ':' ) ) {
[740] Fix | Delete
$stack = explode( ' ', $tempheader, 3 );
[741] Fix | Delete
$stack[] = '';
[742] Fix | Delete
list( , $response['code'], $response['message']) = $stack;
[743] Fix | Delete
continue;
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
list($key, $value) = explode( ':', $tempheader, 2 );
[747] Fix | Delete
[748] Fix | Delete
$key = strtolower( $key );
[749] Fix | Delete
$value = trim( $value );
[750] Fix | Delete
[751] Fix | Delete
if ( isset( $newheaders[ $key ] ) ) {
[752] Fix | Delete
if ( ! is_array( $newheaders[ $key ] ) ) {
[753] Fix | Delete
$newheaders[ $key ] = array( $newheaders[ $key ] );
[754] Fix | Delete
}
[755] Fix | Delete
$newheaders[ $key ][] = $value;
[756] Fix | Delete
} else {
[757] Fix | Delete
$newheaders[ $key ] = $value;
[758] Fix | Delete
}
[759] Fix | Delete
if ( 'set-cookie' === $key ) {
[760] Fix | Delete
$cookies[] = new WP_Http_Cookie( $value, $url );
[761] Fix | Delete
}
[762] Fix | Delete
}
[763] Fix | Delete
[764] Fix | Delete
// Cast the Response Code to an int.
[765] Fix | Delete
$response['code'] = (int) $response['code'];
[766] Fix | Delete
[767] Fix | Delete
return array(
[768] Fix | Delete
'response' => $response,
[769] Fix | Delete
'headers' => $newheaders,
[770] Fix | Delete
'cookies' => $cookies,
[771] Fix | Delete
);
[772] Fix | Delete
}
[773] Fix | Delete
[774] Fix | Delete
/**
[775] Fix | Delete
* Takes the arguments for a ::request() and checks for the cookie array.
[776] Fix | Delete
*
[777] Fix | Delete
* If it's found, then it upgrades any basic name => value pairs to WP_Http_Cookie instances,
[778] Fix | Delete
* which are each parsed into strings and added to the Cookie: header (within the arguments array).
[779] Fix | Delete
* Edits the array by reference.
[780] Fix | Delete
*
[781] Fix | Delete
* @since 2.8.0
[782] Fix | Delete
*
[783] Fix | Delete
* @param array $r Full array of args passed into ::request()
[784] Fix | Delete
*/
[785] Fix | Delete
public static function buildCookieHeader( &$r ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
[786] Fix | Delete
if ( ! empty( $r['cookies'] ) ) {
[787] Fix | Delete
// Upgrade any name => value cookie pairs to WP_HTTP_Cookie instances.
[788] Fix | Delete
foreach ( $r['cookies'] as $name => $value ) {
[789] Fix | Delete
if ( ! is_object( $value ) ) {
[790] Fix | Delete
$r['cookies'][ $name ] = new WP_Http_Cookie(
[791] Fix | Delete
array(
[792] Fix | Delete
'name' => $name,
[793] Fix | Delete
'value' => $value,
[794] Fix | Delete
)
[795] Fix | Delete
);
[796] Fix | Delete
}
[797] Fix | Delete
}
[798] Fix | Delete
[799] Fix | Delete
$cookies_header = '';
[800] Fix | Delete
foreach ( (array) $r['cookies'] as $cookie ) {
[801] Fix | Delete
$cookies_header .= $cookie->getHeaderValue() . '; ';
[802] Fix | Delete
}
[803] Fix | Delete
[804] Fix | Delete
$cookies_header = substr( $cookies_header, 0, -2 );
[805] Fix | Delete
$r['headers']['cookie'] = $cookies_header;
[806] Fix | Delete
}
[807] Fix | Delete
}
[808] Fix | Delete
[809] Fix | Delete
/**
[810] Fix | Delete
* Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
[811] Fix | Delete
*
[812] Fix | Delete
* Based off the HTTP http_encoding_dechunk function.
[813] Fix | Delete
*
[814] Fix | Delete
* @link https://tools.ietf.org/html/rfc2616#section-19.4.6 Process for chunked decoding.
[815] Fix | Delete
*
[816] Fix | Delete
* @since 2.7.0
[817] Fix | Delete
*
[818] Fix | Delete
* @param string $body Body content.
[819] Fix | Delete
* @return string Chunked decoded body on success or raw body on failure.
[820] Fix | Delete
*/
[821] Fix | Delete
public static function chunkTransferDecode( $body ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid
[822] Fix | Delete
// The body is not chunked encoded or is malformed.
[823] Fix | Delete
if ( ! preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', trim( $body ) ) ) {
[824] Fix | Delete
return $body;
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
$parsed_body = '';
[828] Fix | Delete
[829] Fix | Delete
// We'll be altering $body, so need a backup in case of error.
[830] Fix | Delete
$body_original = $body;
[831] Fix | Delete
[832] Fix | Delete
while ( true ) {
[833] Fix | Delete
$has_chunk = (bool) preg_match( '/^([0-9a-f]+)[^\r\n]*\r\n/i', $body, $match );
[834] Fix | Delete
if ( ! $has_chunk || empty( $match[1] ) ) {
[835] Fix | Delete
return $body_original;
[836] Fix | Delete
}
[837] Fix | Delete
[838] Fix | Delete
$length = hexdec( $match[1] );
[839] Fix | Delete
$chunk_length = strlen( $match[0] );
[840] Fix | Delete
[841] Fix | Delete
// Parse out the chunk of data.
[842] Fix | Delete
$parsed_body .= substr( $body, $chunk_length, $length );
[843] Fix | Delete
[844] Fix | Delete
// Remove the chunk from the raw data.
[845] Fix | Delete
$body = substr( $body, $length + $chunk_length );
[846] Fix | Delete
[847] Fix | Delete
// End of the document.
[848] Fix | Delete
if ( '0' === trim( $body ) ) {
[849] Fix | Delete
return $parsed_body;
[850] Fix | Delete
}
[851] Fix | Delete
}
[852] Fix | Delete
}
[853] Fix | Delete
[854] Fix | Delete
/**
[855] Fix | Delete
* Determines whether an HTTP API request to the given URL should be blocked.
[856] Fix | Delete
*
[857] Fix | Delete
* Those who are behind a proxy and want to prevent access to certain hosts may do so. This will
[858] Fix | Delete
* prevent plugins from working and core functionality, if you don't include `api.wordpress.org`.
[859] Fix | Delete
*
[860] Fix | Delete
* You block external URL requests by defining `WP_HTTP_BLOCK_EXTERNAL` as true in your `wp-config.php`
[861] Fix | Delete
* file and this will only allow localhost and your site to make requests. The constant
[862] Fix | Delete
* `WP_ACCESSIBLE_HOSTS` will allow additional hosts to go through for requests. The format of the
[863] Fix | Delete
* `WP_ACCESSIBLE_HOSTS` constant is a comma separated list of hostnames to allow, wildcard domains
[864] Fix | Delete
* are supported, eg `*.wordpress.org` will allow for all subdomains of `wordpress.org` to be contacted.
[865] Fix | Delete
*
[866] Fix | Delete
* @since 2.8.0
[867] Fix | Delete
*
[868] Fix | Delete
* @link https://core.trac.wordpress.org/ticket/8927 Allow preventing external requests.
[869] Fix | Delete
* @link https://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS
[870] Fix | Delete
*
[871] Fix | Delete
* @param string $uri URI of url.
[872] Fix | Delete
* @return bool True to block, false to allow.
[873] Fix | Delete
*/
[874] Fix | Delete
public function block_request( $uri ) {
[875] Fix | Delete
// We don't need to block requests, because nothing is blocked.
[876] Fix | Delete
if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL ) {
[877] Fix | Delete
return false;
[878] Fix | Delete
}
[879] Fix | Delete
[880] Fix | Delete
$check = parse_url( $uri );
[881] Fix | Delete
if ( ! $check ) {
[882] Fix | Delete
return true;
[883] Fix | Delete
}
[884] Fix | Delete
[885] Fix | Delete
$home = parse_url( get_option( 'siteurl' ) );
[886] Fix | Delete
[887] Fix | Delete
// Don't block requests back to ourselves by default.
[888] Fix | Delete
if ( 'localhost' === $check['host'] || ( isset( $home['host'] ) && $home['host'] === $check['host'] ) ) {
[889] Fix | Delete
/**
[890] Fix | Delete
* Filters whether to block local HTTP API requests.
[891] Fix | Delete
*
[892] Fix | Delete
* A local request is one to `localhost` or to the same host as the site itself.
[893] Fix | Delete
*
[894] Fix | Delete
* @since 2.8.0
[895] Fix | Delete
*
[896] Fix | Delete
* @param bool $block Whether to block local requests. Default false.
[897] Fix | Delete
*/
[898] Fix | Delete
return apply_filters( 'block_local_requests', false );
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
if ( ! defined( 'WP_ACCESSIBLE_HOSTS' ) ) {
[902] Fix | Delete
return true;
[903] Fix | Delete
}
[904] Fix | Delete
[905] Fix | Delete
static $accessible_hosts = null;
[906] Fix | Delete
static $wildcard_regex = array();
[907] Fix | Delete
if ( null === $accessible_hosts ) {
[908] Fix | Delete
$accessible_hosts = preg_split( '|,\s*|', WP_ACCESSIBLE_HOSTS );
[909] Fix | Delete
[910] Fix | Delete
if ( str_contains( WP_ACCESSIBLE_HOSTS, '*' ) ) {
[911] Fix | Delete
$wildcard_regex = array();
[912] Fix | Delete
foreach ( $accessible_hosts as $host ) {
[913] Fix | Delete
$wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) );
[914] Fix | Delete
}
[915] Fix | Delete
$wildcard_regex = '/^(' . implode( '|', $wildcard_regex ) . ')$/i';
[916] Fix | Delete
}
[917] Fix | Delete
}
[918] Fix | Delete
[919] Fix | Delete
if ( ! empty( $wildcard_regex ) ) {
[920] Fix | Delete
return ! preg_match( $wildcard_regex, $check['host'] );
[921] Fix | Delete
} else {
[922] Fix | Delete
return ! in_array( $check['host'], $accessible_hosts, true ); // Inverse logic, if it's in the array, then don't block it.
[923] Fix | Delete
}
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
/**
[927] Fix | Delete
* Used as a wrapper for PHP's parse_url() function that handles edgecases in < PHP 5.4.7.
[928] Fix | Delete
*
[929] Fix | Delete
* @deprecated 4.4.0 Use wp_parse_url()
[930] Fix | Delete
* @see wp_parse_url()
[931] Fix | Delete
*
[932] Fix | Delete
* @param string $url The URL to parse.
[933] Fix | Delete
* @return bool|array False on failure; Array of URL components on success;
[934] Fix | Delete
* See parse_url()'s return values.
[935] Fix | Delete
*/
[936] Fix | Delete
protected static function parse_url( $url ) {
[937] Fix | Delete
_deprecated_function( __METHOD__, '4.4.0', 'wp_parse_url()' );
[938] Fix | Delete
return wp_parse_url( $url );
[939] Fix | Delete
}
[940] Fix | Delete
[941] Fix | Delete
/**
[942] Fix | Delete
* Converts a relative URL to an absolute URL relative to a given URL.
[943] Fix | Delete
*
[944] Fix | Delete
* If an Absolute URL is provided, no processing of that URL is done.
[945] Fix | Delete
*
[946] Fix | Delete
* @since 3.4.0
[947] Fix | Delete
*
[948] Fix | Delete
* @param string $maybe_relative_path The URL which might be relative.
[949] Fix | Delete
* @param string $url The URL which $maybe_relative_path is relative to.
[950] Fix | Delete
* @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned.
[951] Fix | Delete
*/
[952] Fix | Delete
public static function make_absolute_url( $maybe_relative_path, $url ) {
[953] Fix | Delete
if ( empty( $url ) ) {
[954] Fix | Delete
return $maybe_relative_path;
[955] Fix | Delete
}
[956] Fix | Delete
[957] Fix | Delete
$url_parts = wp_parse_url( $url );
[958] Fix | Delete
if ( ! $url_parts ) {
[959] Fix | Delete
return $maybe_relative_path;
[960] Fix | Delete
}
[961] Fix | Delete
[962] Fix | Delete
$relative_url_parts = wp_parse_url( $maybe_relative_path );
[963] Fix | Delete
if ( ! $relative_url_parts ) {
[964] Fix | Delete
return $maybe_relative_path;
[965] Fix | Delete
}
[966] Fix | Delete
[967] Fix | Delete
// Check for a scheme on the 'relative' URL.
[968] Fix | Delete
if ( ! empty( $relative_url_parts['scheme'] ) ) {
[969] Fix | Delete
return $maybe_relative_path;
[970] Fix | Delete
}
[971] Fix | Delete
[972] Fix | Delete
$absolute_path = $url_parts['scheme'] . '://';
[973] Fix | Delete
[974] Fix | Delete
// Schemeless URLs will make it this far, so we check for a host in the relative URL
[975] Fix | Delete
// and convert it to a protocol-URL.
[976] Fix | Delete
if ( isset( $relative_url_parts['host'] ) ) {
[977] Fix | Delete
$absolute_path .= $relative_url_parts['host'];
[978] Fix | Delete
if ( isset( $relative_url_parts['port'] ) ) {
[979] Fix | Delete
$absolute_path .= ':' . $relative_url_parts['port'];
[980] Fix | Delete
}
[981] Fix | Delete
} else {
[982] Fix | Delete
$absolute_path .= $url_parts['host'];
[983] Fix | Delete
if ( isset( $url_parts['port'] ) ) {
[984] Fix | Delete
$absolute_path .= ':' . $url_parts['port'];
[985] Fix | Delete
}
[986] Fix | Delete
}
[987] Fix | Delete
[988] Fix | Delete
// Start off with the absolute URL path.
[989] Fix | Delete
$path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/';
[990] Fix | Delete
[991] Fix | Delete
// If it's a root-relative path, then great.
[992] Fix | Delete
if ( ! empty( $relative_url_parts['path'] ) && '/' === $relative_url_parts['path'][0] ) {
[993] Fix | Delete
$path = $relative_url_parts['path'];
[994] Fix | Delete
[995] Fix | Delete
// Else it's a relative path.
[996] Fix | Delete
} elseif ( ! empty( $relative_url_parts['path'] ) ) {
[997] Fix | Delete
// Strip off any file components from the absolute path.
[998] Fix | Delete
$path = substr( $path, 0, strrpos( $path, '/' ) + 1 );
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function