From 030747e429a32d71306fff9e3f744f387c43c0bb Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 15 Sep 2015 02:53:18 +0000 Subject: [PATCH] Add a filter to allow custom headers to be sent via the WP HTTP IXR client: `'wp_http_ixr_client_headers'`. Props ericmann. Fixes #24598. git-svn-id: https://develop.svn.wordpress.org/trunk@34164 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-http-ixr-client.php | 21 ++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-http-ixr-client.php b/src/wp-includes/class-wp-http-ixr-client.php index e0309bf9f4..769aa17669 100644 --- a/src/wp-includes/class-wp-http-ixr-client.php +++ b/src/wp-includes/class-wp-http-ixr-client.php @@ -64,15 +64,27 @@ class WP_HTTP_IXR_Client extends IXR_Client { ); // Merge Custom headers ala #8145 - foreach ( $this->headers as $header => $value ) + foreach ( $this->headers as $header => $value ) { $args['headers'][$header] = $value; + } - if ( $this->timeout !== false ) + /** + * Filter to allow custom headers to be sent + * + * @since 4.4.0 + * + * @param array $headers Header collection to be sent to the XML-RPC server. + */ + $args['headers'] = apply_filters( 'wp_http_ixr_client_headers', $args['headers'] ); + + if ( $this->timeout !== false ) { $args['timeout'] = $this->timeout; + } // Now send the request - if ( $this->debug ) + if ( $this->debug ) { echo '
' . htmlspecialchars($xml) . "\n
\n\n"; + } $response = wp_remote_post($url, $args); @@ -88,8 +100,9 @@ class WP_HTTP_IXR_Client extends IXR_Client { return false; } - if ( $this->debug ) + if ( $this->debug ) { echo '
' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n
\n\n"; + } // Now parse what we've got back $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) );