scheme'] ) ) {
return $maybe_relative_path;
}
$absolute_path = $url_parts['scheme'] . '://';
// Schemeless URLs will make it this far, so we check for a host in the relative URL
// and convert it to a protocol-URL.
if ( isset( $relative_url_parts['host'] ) ) {
$absolute_path .= $relative_url_parts['host'];
if ( isset( $relative_url_parts['port'] ) ) {
$absolute_path .= ':' . $relative_url_parts['port'];
}
} else {
$absolute_path .= $url_parts['host'];
if ( isset( $url_parts['port'] ) ) {
$absolute_path .= ':' . $url_parts['port'];
}
}
// Start off with the absolute URL path.
$path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/';
// If it's a root-relative path, then great.
if ( ! empty( $relative_url_parts['path'] ) && '/' === $relative_url_parts['path'][0] ) {
$path = $relative_url_parts['path'];
// Else it's a relative path.
} elseif ( ! empty( $relative_url_parts['path'] ) ) {
// Strip off any file components from the absolute path.
$path = substr( $path, 0, strrpos( $path, '/' ) + 1 );
// Build the new path.
$path .= $relative_url_parts['path'];
// Strip all /path/../ out of the path.
while ( strpos( $path, '../' ) > 1 ) {
$path = preg_replace( '![^/]+/\.\./!', '', $path );
}
// Strip any final leading ../ from the path.
$path = preg_replace( '!^/(\.\./)+!', '', $path );
}
// Add the query string.
if ( ! empty( $relative_url_parts['query'] ) ) {
$path .= '?' . $relative_url_parts['query'];
}
// Add the fragment.
if ( ! empty( $relative_url_parts['fragment'] ) ) {
$path .= '#' . $relative_url_parts['fragment'];
}
return $absolute_path . '/' . ltrim( $path, '/' );
}
/**
* Handles an HTTP redirect and follows it if appropriate.
*
* @since 3.7.0
*
* @param string $url The URL which was requested.
* @param array $args The arguments which were used to make the request.
* @param array $response The response of the HTTP request.
* @return array|false|WP_Error An HTTP API response array if the redirect is successfully followed,
* false if no redirect is present, or a WP_Error object if there's an error.
*/
public static function handle_redirects( $url, $args, $response ) {
// If no redirects are present, or, redirects were not requested, perform no action.
if ( ! isset( $response['headers']['location'] ) || 0 === $args['_redirection'] ) {
return false;
}
// Only perform redirections on redirection http codes.
if ( $response['response']['code'] > 399 || $response['response']['code'] < 300 ) {
return false;
}
// Don't redirect if we've run out of redirects.
if ( $args['redirection']-- <= 0 ) {
return new WP_Error( 'http_request_failed', __( 'Too many redirects.' ) );
}
$redirect_location = $response['headers']['location'];
// If there were multiple Location headers, use the last header specified.
if ( is_array( $redirect_location ) ) {
$redirect_location = array_pop( $redirect_location );
}
$redirect_location = WP_Http::make_absolute_url( $redirect_location, $url );
// POST requests should not POST to a redirected location.
if ( 'POST' === $args['method'] ) {
if ( in_array( $response['response']['code'], array( 302, 303 ), true ) ) {
$args['method'] = 'GET';
}
}
// Include valid cookies in the redirect process.
if ( ! empty( $response['cookies'] ) ) {
foreach ( $response['cookies'] as $cookie ) {
if ( $cookie->test( $redirect_location ) ) {
$args['cookies'][] = $cookie;
}
}
}
return wp_remote_request( $redirect_location, $args );
}
/**
* Determines if a specified string represents an IP address or not.
*
* This function also detects the type of the IP address, returning either
* '4' or '6' to represent an IPv4 and IPv6 address respectively.
* This does not verify if the IP is a valid IP, only that it appears to be
* an IP address.
*
* @link http://home.deds.nl/~aeron/regex/ for IPv6 regex.
*
* @since 3.7.0
*
* @param string $maybe_ip A suspected IP address.
* @return int|false Upon success, '4' or '6' to represent an IPv4 or IPv6 address, false upon failure.
*/
public static function is_ip_address( $maybe_ip ) {
if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $maybe_ip ) ) {
return 4;
}
if ( str_contains( $maybe_ip, ':' ) && preg_match( '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i', trim( $maybe_ip, ' []' ) ) ) {
return 6;
}
return false;
}
}
Fatal error: Uncaught Error: Class 'WpOrg\Requests\Hooks' not found in /home/ocb/public_html/wp-includes/class-wp-http-requests-hooks.php:18
Stack trace:
#0 /home/ocb/public_html/wp-settings.php(276): require()
#1 /home/ocb/public_html/wp-config.php(77): require_once('/home/ocb/publi...')
#2 /home/ocb/public_html/wp-load.php(50): require_once('/home/ocb/publi...')
#3 /home/ocb/public_html/wp-blog-header.php(13): require_once('/home/ocb/publi...')
#4 /home/ocb/public_html/index.php(17): require('/home/ocb/publi...')
#5 {main}
thrown in /home/ocb/public_html/wp-includes/class-wp-http-requests-hooks.php on line 18
Fatal error: Uncaught Error: Call to a member function set() on null in /home/ocb/public_html/wp-includes/l10n.php:856
Stack trace:
#0 /home/ocb/public_html/wp-includes/l10n.php(959): load_textdomain('default', '/home/ocb/publi...', 'lv')
#1 /home/ocb/public_html/wp-includes/class-wp-fatal-error-handler.php(49): load_default_textdomain()
#2 [internal function]: WP_Fatal_Error_Handler->handle()
#3 {main}
thrown in /home/ocb/public_html/wp-includes/l10n.php on line 856