mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Use wp_remote_retrieve_* helper functions instead of the raw HTTP response array. props aaroncampbell, fixes #17416.
git-svn-id: https://develop.svn.wordpress.org/trunk@17928 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user