diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index c558be5cc7..0da6500321 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -1208,10 +1208,10 @@ function wp_check_browser_version() { 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); - $raw_response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options ); + $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.0/', $options ); - if ( is_wp_error( $raw_response ) || 200 != $raw_response['response']['code'] ) - return; + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) + return false; /** * Response should be an array with: @@ -1224,7 +1224,7 @@ function wp_check_browser_version() { * 'img_src' - string - An image representing the browser * 'img_src_ssl' - string - An image (over SSL) representing the browser */ - $response = unserialize( $raw_response['body'] ); + $response = unserialize( wp_remote_retrieve_body( $response ) ); if ( ! $response ) return; diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index f77cc6493d..d91dc6832e 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -490,9 +490,9 @@ function download_url( $url, $timeout = 300 ) { return $response; } - if ( $response['response']['code'] != '200' ){ + if ( 200 != wp_remote_retrieve_response_code( $response ) ){ unlink( $tmpfname ); - return new WP_Error( 'http_404', trim( $response['response']['message'] ) ); + return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) ); } return $tmpfname; diff --git a/wp-admin/includes/plugin-install.php b/wp-admin/includes/plugin-install.php index beb54676f1..66996c8c00 100644 --- a/wp-admin/includes/plugin-install.php +++ b/wp-admin/includes/plugin-install.php @@ -45,9 +45,9 @@ function plugins_api($action, $args = null) { if ( is_wp_error($request) ) { $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() ); } else { - $res = unserialize($request['body']); + $res = unserialize( wp_remote_retrieve_body( $request ) ); if ( false === $res ) - $res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), $request['body']); + $res = new WP_Error('plugins_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) ); } } elseif ( !is_wp_error($res) ) { $res->external = true; @@ -367,4 +367,3 @@ function install_plugin_information() { exit; } add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); - diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index 81e6afdf05..1834153e88 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -762,7 +762,7 @@ Thanks! $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); if ( is_wp_error( $page ) ) $errstr = $page->get_error_message(); - elseif ( 200 == $page['response']['code'] ) + elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) $vhost_ok = true; if ( ! $vhost_ok ) { diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 3cdb1e02c5..dee6d3ff2a 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -396,9 +396,9 @@ function themes_api($action, $args = null) { if ( is_wp_error($request) ) { $res = new WP_Error('themes_api_failed', __('An Unexpected HTTP Error occurred during the API request.'), $request->get_error_message() ); } else { - $res = unserialize($request['body']); + $res = unserialize( wp_remote_retrieve_body( $request ) ); if ( ! $res ) - $res = new WP_Error('themes_api_failed', __('An unknown error occurred.'), $request['body']); + $res = new WP_Error('themes_api_failed', __('An unknown error occurred.'), wp_remote_retrieve_body( $request ) ); } } //var_dump(array($args, $res)); diff --git a/wp-includes/class-feed.php b/wp-includes/class-feed.php index 7ae7cc833d..067f36c2c6 100644 --- a/wp-includes/class-feed.php +++ b/wp-includes/class-feed.php @@ -80,9 +80,9 @@ class WP_SimplePie_File extends SimplePie_File { $this->error = 'WP HTTP Error: ' . $res->get_error_message(); $this->success = false; } else { - $this->headers = $res['headers']; - $this->body = $res['body']; - $this->status_code = $res['response']['code']; + $this->headers = wp_remote_retrieve_headers( $res ); + $this->body = wp_remote_retrieve_body( $res ); + $this->status_code = wp_remote_retrieve_response_code( $res ); } } else { if ( ! $this->body = file_get_contents($url) ) { @@ -91,4 +91,4 @@ class WP_SimplePie_File extends SimplePie_File { } } } -} \ No newline at end of file +} diff --git a/wp-includes/class-wp-http-ixr-client.php b/wp-includes/class-wp-http-ixr-client.php index 994ae5726a..9e202ed63c 100644 --- a/wp-includes/class-wp-http-ixr-client.php +++ b/wp-includes/class-wp-http-ixr-client.php @@ -64,16 +64,16 @@ class WP_HTTP_IXR_Client extends IXR_Client { return false; } - if ( $response['response']['code'] != 200 ) { - $this->error = new IXR_Error(-32301, "transport error - HTTP status code was not 200 ({$response['response']['code']})"); + if ( 200 != wp_remote_retrieve_response_code( $response ) ) { + $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')'); return false; } if ( $this->debug ) - echo '
' . htmlspecialchars($response['body']) . "\n
\n\n"; + echo '
' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n
\n\n"; // Now parse what we've got back - $this->message = new IXR_Message( $response['body'] ); + $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) ); if ( ! $this->message->parse() ) { // XML error $this->error = new IXR_Error(-32700, 'parse error. not well formed'); @@ -90,4 +90,4 @@ class WP_HTTP_IXR_Client extends IXR_Client { return true; } } -?> \ No newline at end of file +?> diff --git a/wp-includes/comment.php b/wp-includes/comment.php index fe873fba64..7a8aa96864 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1619,11 +1619,11 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { if ( is_wp_error( $response ) ) return false; - if ( isset( $response['headers']['x-pingback'] ) ) - return $response['headers']['x-pingback']; + if ( wp_remote_retrieve_header( $response, 'x-pingback' ) ) + return wp_remote_retrieve_header( $response, 'x-pingback' ); // Not an (x)html, sgml, or xml page, no use going further. - if ( isset( $response['headers']['content-type'] ) && preg_match('#(image|audio|video|model)/#is', $response['headers']['content-type']) ) + if ( preg_match('#(image|audio|video|model)/#is', wp_remote_retrieve_header( $response, 'content-type' )) ) return false; // Now do a GET since we're going to look in the html headers (and we're sure its not a binary file) @@ -1632,7 +1632,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { if ( is_wp_error( $response ) ) return false; - $contents = $response['body']; + $contents = wp_remote_retrieve_body( $response ); $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote); $pingback_link_offset_squote = strpos($contents, $pingback_str_squote); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 575b78ce15..999b8d0408 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -600,7 +600,7 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) wp_protect_special_option( $option ); - /* + /* * FIXME the next two lines of code are not necessary and should be removed. * @see http://core.trac.wordpress.org/ticket/13480 */ @@ -1305,7 +1305,7 @@ function wp_get_http( $url, $file_path = false, $red = 1 ) { return false; $headers = wp_remote_retrieve_headers( $response ); - $headers['response'] = $response['response']['code']; + $headers['response'] = wp_remote_retrieve_response_code( $response ); // WP_HTTP no longer follows redirects for HEAD requests. if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { @@ -1320,7 +1320,7 @@ function wp_get_http( $url, $file_path = false, $red = 1 ) { if ( !$out_fp ) return $headers; - fwrite( $out_fp, $response['body']); + fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); fclose($out_fp); clearstatcache(); @@ -1556,7 +1556,7 @@ function wp_remote_fopen( $uri ) { if ( is_wp_error( $response ) ) return false; - return $response['body']; + return wp_remote_retrieve_body( $response ); } /** @@ -2876,26 +2876,26 @@ if ( 'rtl' == $text_direction ) : ?> * @param string $title Error title. * @param string|array $args Optional arguements to control behaviour. */ -function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { +function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { global $wp_xmlrpc_server; $defaults = array( 'response' => 500 ); $r = wp_parse_args($args, $defaults); - if ( $wp_xmlrpc_server ) { - $error = new IXR_Error( $r['response'] , $message); - $wp_xmlrpc_server->output( $error->getXml() ); + if ( $wp_xmlrpc_server ) { + $error = new IXR_Error( $r['response'] , $message); + $wp_xmlrpc_server->output( $error->getXml() ); } die(); } /** * Filter to enable special wp_die handler for xmlrpc requests. - * + * * @since 3.2.0 * @access private */ -function _xmlrpc_wp_die_filter() { +function _xmlrpc_wp_die_filter() { return '_xmlrpc_wp_die_handler'; } diff --git a/wp-includes/rss.php b/wp-includes/rss.php index f23730d0ee..88bfa62dcb 100644 --- a/wp-includes/rss.php +++ b/wp-includes/rss.php @@ -555,7 +555,7 @@ function _fetch_remote_file($url, $headers = "" ) { // Snoopy returns headers unprocessed. // Also note, WP_HTTP lowercases all keys, Snoopy did not. $return_headers = array(); - foreach ( $resp['headers'] as $key => $value ) { + foreach ( wp_remote_retrieve_headers( $resp ) as $key => $value ) { if ( !is_array($value) ) { $return_headers[] = "$key: $value"; } else { @@ -565,10 +565,10 @@ function _fetch_remote_file($url, $headers = "" ) { } $response = new stdClass; - $response->status = $resp['response']['code']; - $response->response_code = $resp['response']['code']; + $response->status = wp_remote_retrieve_response_code( $resp ); + $response->response_code = wp_remote_retrieve_response_code( $resp ); $response->headers = $return_headers; - $response->results = $resp['body']; + $response->results = wp_remote_retrieve_body( $resp ); return $response; } diff --git a/wp-includes/update.php b/wp-includes/update.php index 191f230119..4d473aed72 100644 --- a/wp-includes/update.php +++ b/wp-includes/update.php @@ -71,13 +71,10 @@ function wp_version_check() { $response = wp_remote_get($url, $options); - if ( is_wp_error( $response ) ) + if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) return false; - if ( 200 != $response['response']['code'] ) - return false; - - $body = trim( $response['body'] ); + $body = trim( wp_remote_retrieve_body( $response ) ); $body = str_replace(array("\r\n", "\r"), "\n", $body); $new_options = array(); foreach ( explode( "\n\n", $body ) as $entry ) { @@ -175,13 +172,10 @@ function wp_update_plugins() { $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options); - if ( is_wp_error( $raw_response ) ) + if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) return false; - if ( 200 != $raw_response['response']['code'] ) - return false; - - $response = unserialize( $raw_response['body'] ); + $response = unserialize( wp_remote_retrieve_body( $raw_response ) ); if ( false !== $response ) $new_option->response = $response; @@ -273,17 +267,14 @@ function wp_update_themes() { $raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options ); - if ( is_wp_error( $raw_response ) ) - return false; - - if ( 200 != $raw_response['response']['code'] ) + if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ) return false; $new_update = new stdClass; $new_update->last_checked = time( ); $new_update->checked = $checked; - $response = unserialize( $raw_response['body'] ); + $response = unserialize( wp_remote_retrieve_body( $raw_response ) ); if ( false !== $response ) $new_update->response = $response;