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
/home/sportsfe.../public_h.../wp-inclu...
File: class-wp-http-ixr-client.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WP_HTTP_IXR_Client
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @since 3.1.0
[5] Fix | Delete
*/
[6] Fix | Delete
#[AllowDynamicProperties]
[7] Fix | Delete
class WP_HTTP_IXR_Client extends IXR_Client {
[8] Fix | Delete
public $scheme;
[9] Fix | Delete
/**
[10] Fix | Delete
* @var IXR_Error
[11] Fix | Delete
*/
[12] Fix | Delete
public $error;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* @param string $server
[16] Fix | Delete
* @param string|false $path
[17] Fix | Delete
* @param int|false $port
[18] Fix | Delete
* @param int $timeout
[19] Fix | Delete
*/
[20] Fix | Delete
public function __construct( $server, $path = false, $port = false, $timeout = 15 ) {
[21] Fix | Delete
if ( ! $path ) {
[22] Fix | Delete
// Assume we have been given a URL instead.
[23] Fix | Delete
$bits = parse_url( $server );
[24] Fix | Delete
$this->scheme = $bits['scheme'];
[25] Fix | Delete
$this->server = $bits['host'];
[26] Fix | Delete
$this->port = isset( $bits['port'] ) ? $bits['port'] : $port;
[27] Fix | Delete
$this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/';
[28] Fix | Delete
[29] Fix | Delete
// Make absolutely sure we have a path.
[30] Fix | Delete
if ( ! $this->path ) {
[31] Fix | Delete
$this->path = '/';
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
if ( ! empty( $bits['query'] ) ) {
[35] Fix | Delete
$this->path .= '?' . $bits['query'];
[36] Fix | Delete
}
[37] Fix | Delete
} else {
[38] Fix | Delete
$this->scheme = 'http';
[39] Fix | Delete
$this->server = $server;
[40] Fix | Delete
$this->path = $path;
[41] Fix | Delete
$this->port = $port;
[42] Fix | Delete
}
[43] Fix | Delete
$this->useragent = 'The Incutio XML-RPC PHP Library';
[44] Fix | Delete
$this->timeout = $timeout;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* @since 3.1.0
[49] Fix | Delete
* @since 5.5.0 Formalized the existing `...$args` parameter by adding it
[50] Fix | Delete
* to the function signature.
[51] Fix | Delete
*
[52] Fix | Delete
* @return bool
[53] Fix | Delete
*/
[54] Fix | Delete
public function query( ...$args ) {
[55] Fix | Delete
$method = array_shift( $args );
[56] Fix | Delete
$request = new IXR_Request( $method, $args );
[57] Fix | Delete
$xml = $request->getXml();
[58] Fix | Delete
[59] Fix | Delete
$port = $this->port ? ":$this->port" : '';
[60] Fix | Delete
$url = $this->scheme . '://' . $this->server . $port . $this->path;
[61] Fix | Delete
$args = array(
[62] Fix | Delete
'headers' => array( 'Content-Type' => 'text/xml' ),
[63] Fix | Delete
'user-agent' => $this->useragent,
[64] Fix | Delete
'body' => $xml,
[65] Fix | Delete
);
[66] Fix | Delete
[67] Fix | Delete
// Merge Custom headers ala #8145.
[68] Fix | Delete
foreach ( $this->headers as $header => $value ) {
[69] Fix | Delete
$args['headers'][ $header ] = $value;
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Filters the headers collection to be sent to the XML-RPC server.
[74] Fix | Delete
*
[75] Fix | Delete
* @since 4.4.0
[76] Fix | Delete
*
[77] Fix | Delete
* @param string[] $headers Associative array of headers to be sent.
[78] Fix | Delete
*/
[79] Fix | Delete
$args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] );
[80] Fix | Delete
[81] Fix | Delete
if ( false !== $this->timeout ) {
[82] Fix | Delete
$args['timeout'] = $this->timeout;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Now send the request.
[86] Fix | Delete
if ( $this->debug ) {
[87] Fix | Delete
echo '<pre class="ixr_request">' . htmlspecialchars( $xml ) . "\n</pre>\n\n";
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
$response = wp_remote_post( $url, $args );
[91] Fix | Delete
[92] Fix | Delete
if ( is_wp_error( $response ) ) {
[93] Fix | Delete
$errno = $response->get_error_code();
[94] Fix | Delete
$errorstr = $response->get_error_message();
[95] Fix | Delete
$this->error = new IXR_Error( -32300, "transport error: $errno $errorstr" );
[96] Fix | Delete
return false;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
[100] Fix | Delete
$this->error = new IXR_Error( -32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')' );
[101] Fix | Delete
return false;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
if ( $this->debug ) {
[105] Fix | Delete
echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n";
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
// Now parse what we've got back.
[109] Fix | Delete
$this->message = new IXR_Message( wp_remote_retrieve_body( $response ) );
[110] Fix | Delete
if ( ! $this->message->parse() ) {
[111] Fix | Delete
// XML error.
[112] Fix | Delete
$this->error = new IXR_Error( -32700, 'parse error. not well formed' );
[113] Fix | Delete
return false;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
// Is the message a fault?
[117] Fix | Delete
if ( 'fault' === $this->message->messageType ) {
[118] Fix | Delete
$this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString );
[119] Fix | Delete
return false;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
// Message must be OK.
[123] Fix | Delete
return true;
[124] Fix | Delete
}
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function