Make WordPress Core

Ticket #14381: 14381.diff

File 14381.diff, 3.4 KB (added by ryan, 14 years ago)
  • wp-includes/update.php

     
    211211                require_once( ABSPATH . 'wp-includes/theme.php' );
    212212
    213213        $installed_themes = get_themes( );
    214         $current_theme = get_site_transient( 'update_themes' );
    215         if ( ! is_object($current_theme) )
    216                 $current_theme = new stdClass;
     214        $last_update = get_site_transient( 'update_themes' );
     215        if ( ! is_object($last_update) )
     216                $last_update = new stdClass;
    217217
    218         $new_option = new stdClass;
    219         $new_option->last_checked = time( );
    220218        $timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
    221         $time_not_changed = isset( $current_theme->last_checked ) && $timeout > ( time( ) - $current_theme->last_checked );
     219        $time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
    222220
    223221        $themes = array();
    224222        $checked = array();
    225         $themes['current_theme'] = (array) $current_theme;
     223
     224        // Put slug of current theme into request.
     225        $themes['current_theme'] = get_option( 'stylesheet' );
     226
    226227        foreach ( (array) $installed_themes as $theme_title => $theme ) {
    227228                $themes[$theme['Stylesheet']] = array();
    228229                $checked[$theme['Stylesheet']] = $theme['Version'];
    229230
    230                 foreach ( (array) $theme as $key => $value )
    231                         $themes[$theme['Stylesheet']][$key] = $value;
     231                $themes[$theme['Stylesheet']]['Name'] = $theme['Name'];
     232                $themes[$theme['Stylesheet']]['Version'] = $theme['Version'];
    232233        }
    233234
    234235        $theme_changed = false;
    235236        foreach ( $checked as $slug => $v ) {
    236                 $new_option->checked[ $slug ] = $v;
     237                $update_request->checked[ $slug ] = $v;
    237238
    238                 if ( !isset( $current_theme->checked[ $slug ] ) || strval($current_theme->checked[ $slug ]) !== strval($v) )
     239                if ( !isset( $last_update->checked[ $slug ] ) || strval($last_update->checked[ $slug ]) !== strval($v) )
    239240                        $theme_changed = true;
    240241        }
    241242
    242         if ( isset ( $current_theme->response ) && is_array( $current_theme->response ) ) {
    243                 foreach ( $current_theme->response as $slug => $update_details ) {
     243        if ( isset ( $last_update->response ) && is_array( $last_update->response ) ) {
     244                foreach ( $last_update->response as $slug => $update_details ) {
    244245                        if ( ! isset($checked[ $slug ]) ) {
    245246                                $theme_changed = true;
    246247                                break;
     
    252253                return false;
    253254
    254255        // Update last_checked for current to prevent multiple blocking requests if request hangs
    255         $current_theme->last_checked = time();
    256         set_site_transient( 'update_themes', $current_theme );
     256        $last_update->last_checked = time();
     257        set_site_transient( 'update_themes', $last_update );
    257258
    258         $current_theme->template = get_option( 'template' );
    259 
    260259        $options = array(
    261260                'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3),
    262261                'body'                  => array( 'themes' => serialize( $themes ) ),
     
    271270        if ( 200 != $raw_response['response']['code'] )
    272271                return false;
    273272
     273        $new_update = new stdClass;
     274        $new_update->last_checked = time( );
    274275        $response = unserialize( $raw_response['body'] );
    275276        if ( $response ) {
    276                 $new_option->checked = $checked;
    277                 $new_option->response = $response;
     277                $new_update->checked = $checked;
     278                $new_update->response = $response;
    278279        }
    279280
    280         set_site_transient( 'update_themes', $new_option );
     281        set_site_transient( 'update_themes', $new_update );
    281282}
    282283
    283284function _maybe_update_core() {