Make WordPress Core


Ignore:
Timestamp:
05/14/2011 07:45:07 PM (14 years ago)
Author:
nacin
Message:

Use wp_remote_retrieve_* helper functions instead of the raw HTTP response array. props aaroncampbell, fixes #17416.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/update.php

    r17619 r17928  
    7272    $response = wp_remote_get($url, $options);
    7373
    74     if ( is_wp_error( $response ) )
    75         return false;
    76 
    77     if ( 200 != $response['response']['code'] )
    78         return false;
    79 
    80     $body = trim( $response['body'] );
     74    if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) )
     75        return false;
     76
     77    $body = trim( wp_remote_retrieve_body( $response ) );
    8178    $body = str_replace(array("\r\n", "\r"), "\n", $body);
    8279    $new_options = array();
     
    176173    $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);
    177174
    178     if ( is_wp_error( $raw_response ) )
    179         return false;
    180 
    181     if ( 200 != $raw_response['response']['code'] )
    182         return false;
    183 
    184     $response = unserialize( $raw_response['body'] );
     175    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
     176        return false;
     177
     178    $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
    185179
    186180    if ( false !== $response )
     
    274268    $raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options );
    275269
    276     if ( is_wp_error( $raw_response ) )
    277         return false;
    278 
    279     if ( 200 != $raw_response['response']['code'] )
     270    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
    280271        return false;
    281272
     
    284275    $new_update->checked = $checked;
    285276
    286     $response = unserialize( $raw_response['body'] );
     277    $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
    287278    if ( false !== $response )
    288279        $new_update->response = $response;
Note: See TracChangeset for help on using the changeset viewer.