Make WordPress Core

Ticket #10611: 10611.diff

File 10611.diff, 5.5 KB (added by nacin, 13 years ago)
  • wp-includes/update.php

     
    5858        }
    5959
    6060        $local_package = isset( $wp_local_package )? $wp_local_package : '';
    61         $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";
    6262
    6363        $options = array(
    6464                'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3 ),
     
    7575                return false;
    7676
    7777        $body = trim( wp_remote_retrieve_body( $response ) );
    78         $body = str_replace(array("\r\n", "\r"), "\n", $body);
    79         $new_options = array();
    80         foreach ( explode( "\n\n", $body ) as $entry ) {
    81                 $returns = explode("\n", $entry);
    82                 $new_option = new stdClass();
    83                 $new_option->response = esc_attr( $returns[0] );
    84                 if ( isset( $returns[1] ) )
    85                         $new_option->url = esc_url( $returns[1] );
    86                 if ( isset( $returns[2] ) )
    87                         $new_option->package = esc_url( $returns[2] );
    88                 if ( isset( $returns[3] ) )
    89                         $new_option->current = esc_attr( $returns[3] );
    90                 if ( isset( $returns[4] ) )
    91                         $new_option->locale = esc_attr( $returns[4] );
    92                 if ( isset( $returns[5] ) )
    93                         $new_option->php_version = esc_attr( $returns[5] );
    94                 if ( isset( $returns[6] ) )
    95                         $new_option->mysql_version = esc_attr( $returns[6] );
    96                 $new_options[] = $new_option;
     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'] ), array_fill_keys( array( 'full', 'no_content', 'new_bundled', 'partial' ), '' ) );
     88                        elseif ( 'download' == $offer_key )
     89                                $offer['download'] = esc_url( $value );
     90                        else
     91                                $offer[ $offer_key ] = esc_html( $value );
     92                }
     93                $offer = (object) array_intersect_key( $offer, array_fill_keys( array( 'response', 'download', 'locale', 'packages', 'current', 'php_version', 'mysql_version', 'new_bundled' ), '' ) );
    9794        }
    9895
     96        var_dump( $offers );
     97
    9998        $updates = new stdClass();
    100         $updates->updates = $new_options;
     99        $updates->updates = $offers;
    101100        $updates->last_checked = time();
    102101        $updates->version_checked = $wp_version;
    103102        set_site_transient( 'update_core',  $updates);
     
    286285
    287286        $current = get_site_transient( 'update_core' );
    288287
    289         if ( isset( $current->last_checked ) &&
     288        if ( false && isset( $current->last_checked ) &&
    290289                43200 > ( time() - $current->last_checked ) &&
    291290                isset( $current->version_checked ) &&
    292291                $current->version_checked == $wp_version )
  • wp-admin/includes/class-wp-upgrader.php

     
    885885
    886886                $wp_dir = trailingslashit($wp_filesystem->abspath());
    887887
    888                 $download = $this->download_package( $current->package );
     888                // If partial update is returned from the API, use that, unless we're doing a reinstall.
     889                // If we cross the new_bundled version number, then use the new_bundled zip.
     890                // Don't though if the constant is set to skip bundled items.
     891                // If the API returns a no_content zip, go with it. Finally, default to the full zip.
     892                if ( $current->packages->partial && 'reinstall' != $current->response )
     893                        $to_download = 'partial';
     894                elseif ( $current->packages->new_bundled && version_compare( $wp_version, $current->new_bundled, '<' )
     895                        && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) )
     896                        $to_download = 'new_bundled';
     897                elseif ( $current->packages->no_content )
     898                        $to_download = 'no_content';
     899                else
     900                        $to_download = 'full';
     901
     902                $download = $this->download_package( $current->packages->$to_download );
    889903                if ( is_wp_error($download) )
    890904                        return $download;
    891905
  • wp-admin/update-core.php

     
    1919
    2020function list_core_update( $update ) {
    2121        global $wp_local_package, $wpdb;
     22        static $primary_button = ' button-primary';
     23
    2224        $version_string = ('en_US' == $update->locale && 'en_US' == get_locale() ) ?
    2325                        $update->current : sprintf("%s&ndash;<strong>%s</strong>", $update->current, $update->locale);
    2426        $current = false;
     
    6365        echo '<input name="version" value="'. esc_attr($update->current) .'" type="hidden"/>';
    6466        echo '<input name="locale" value="'. esc_attr($update->locale) .'" type="hidden"/>';
    6567        if ( $show_buttons ) {
    66                 submit_button( $submit, 'button', 'upgrade', false );
    67                 echo '&nbsp;<a href="' . esc_url($update->package) . '" class="button">' . $download . '</a>&nbsp;';
     68                submit_button( $submit, 'button' . $primary_button, 'upgrade', false );
     69                $primary_button = '';
     70                echo '&nbsp;<a href="' . esc_url( $update->download ) . '" class="button">' . $download . '</a>&nbsp;';
    6871        }
    6972        if ( 'en_US' != $update->locale )
    7073                if ( !isset( $update->dismissed ) || !$update->dismissed )