Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r17231 r18227  
    2424        return;
    2525
    26     global $wp_version, $wpdb, $wp_local_package;
     26    global $wpdb, $wp_local_package;
     27    include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
    2728    $php_version = phpversion();
    2829
     
    5859
    5960    $local_package = isset( $wp_local_package )? $wp_local_package : '';
    60     $url = "http://api.wordpress.org/core/version-check/1.5/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
     61    $url = "http://api.wordpress.org/core/version-check/1.6-beta/?version=$wp_version&php=$php_version&locale=$locale&mysql=$mysql_version&local_package=$local_package&blogs=$num_blogs&users={$user_count['total_users']}&multisite_enabled=$multisite_enabled";
    6162
    6263    $options = array(
     
    7172    $response = wp_remote_get($url, $options);
    7273
    73     if ( is_wp_error( $response ) )
    74         return false;
    75 
    76     if ( 200 != $response['response']['code'] )
    77         return false;
    78 
    79     $body = trim( $response['body'] );
    80     $body = str_replace(array("\r\n", "\r"), "\n", $body);
    81     $new_options = array();
    82     foreach ( explode( "\n\n", $body ) as $entry ) {
    83         $returns = explode("\n", $entry);
    84         $new_option = new stdClass();
    85         $new_option->response = esc_attr( $returns[0] );
    86         if ( isset( $returns[1] ) )
    87             $new_option->url = esc_url( $returns[1] );
    88         if ( isset( $returns[2] ) )
    89             $new_option->package = esc_url( $returns[2] );
    90         if ( isset( $returns[3] ) )
    91             $new_option->current = esc_attr( $returns[3] );
    92         if ( isset( $returns[4] ) )
    93             $new_option->locale = esc_attr( $returns[4] );
    94         if ( isset( $returns[5] ) )
    95             $new_option->php_version = esc_attr( $returns[5] );
    96         if ( isset( $returns[6] ) )
    97             $new_option->mysql_version = esc_attr( $returns[6] );
    98         $new_options[] = $new_option;
     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 ) );
     78    if ( ! $body = maybe_unserialize( $body ) )
     79        return false;
     80    if ( ! isset( $body['offers'] ) )
     81        return false;
     82    $offers = $body['offers'];
     83
     84    foreach ( $offers as &$offer ) {
     85        foreach ( $offer as $offer_key => $value ) {
     86            if ( 'packages' == $offer_key )
     87                $offer['packages'] = (object) array_intersect_key( array_map( 'esc_url', $offer['packages'] ),
     88                    array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial' ), '' ) );
     89            elseif ( 'download' == $offer_key )
     90                $offer['download'] = esc_url( $value );
     91            else
     92                $offer[ $offer_key ] = esc_html( $value );
     93        }
     94        $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale',
     95            'packages', 'current', 'php_version', 'mysql_version', 'new_bundled', 'partial_version' ), '' ) );
    9996    }
    10097
    10198    $updates = new stdClass();
    102     $updates->updates = $new_options;
     99    $updates->updates = $offers;
    103100    $updates->last_checked = time();
    104101    $updates->version_checked = $wp_version;
     
    120117 */
    121118function wp_update_plugins() {
    122     global $wp_version;
     119    include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
    123120
    124121    if ( defined('WP_INSTALLING') )
     
    175172    $raw_response = wp_remote_post('http://api.wordpress.org/plugins/update-check/1.0/', $options);
    176173
    177     if ( is_wp_error( $raw_response ) )
    178         return false;
    179 
    180     if ( 200 != $raw_response['response']['code'] )
    181         return false;
    182 
    183     $response = unserialize( $raw_response['body'] );
     174    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
     175        return false;
     176
     177    $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
    184178
    185179    if ( false !== $response )
     
    204198 * @return mixed Returns null if update is unsupported. Returns false if check is too soon.
    205199 */
    206 function wp_update_themes( ) {
    207     global $wp_version;
     200function wp_update_themes() {
     201    include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
    208202
    209203    if ( defined( 'WP_INSTALLING' ) )
     
    273267    $raw_response = wp_remote_post( 'http://api.wordpress.org/themes/update-check/1.0/', $options );
    274268
    275     if ( is_wp_error( $raw_response ) )
    276         return false;
    277 
    278     if ( 200 != $raw_response['response']['code'] )
     269    if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) )
    279270        return false;
    280271
    281272    $new_update = new stdClass;
    282273    $new_update->last_checked = time( );
    283     $response = unserialize( $raw_response['body'] );
    284     if ( $response ) {
    285         $new_update->checked = $checked;
     274    $new_update->checked = $checked;
     275
     276    $response = unserialize( wp_remote_retrieve_body( $raw_response ) );
     277    if ( false !== $response )
    286278        $new_update->response = $response;
    287     }
    288279
    289280    set_site_transient( 'update_themes', $new_update );
     
    291282
    292283function _maybe_update_core() {
    293     global $wp_version;
     284    include ABSPATH . WPINC . '/version.php'; // include an unmodified $wp_version
    294285
    295286    $current = get_site_transient( 'update_core' );
Note: See TracChangeset for help on using the changeset viewer.