WordPress.org

Make WordPress Core

Ticket #10220: 10220.diff

File 10220.diff, 2.2 KB (added by Denis-de-Bernardy, 9 years ago)
  • wp-includes/update.php

     
    201201        $timeout = 'load-themes.php' == current_filter() ? 3600 : 43200; //Check for updated every 60 minutes if hitting the themes page, Else, check every 12 hours
    202202        $time_not_changed = isset( $current_theme->last_checked ) && $timeout > ( time( ) - $current_theme->last_checked );
    203203
    204         if( $time_not_changed )
     204        $themes = array();
     205        $checked = array();
     206        $themes['current_theme'] = (array) $current_theme;
     207        foreach( (array) $installed_themes as $theme_title => $theme ) {
     208                $themes[$theme['Stylesheet']] = array();
     209                $checked[$theme['Stylesheet']] = $theme['Version'];
     210
     211                foreach( (array) $theme as $key => $value ) {
     212                        $themes[$theme['Stylesheet']][$key] = $value;
     213                }
     214        }
     215
     216        $theme_changed = false;
     217        foreach ( $checked as $slug => $v ) {
     218                $new_option->checked[ $slug ] = $v;
     219
     220                if ( !isset( $current_theme->checked[ $slug ] ) || strval($current_theme->checked[ $slug ]) !== strval($v) )
     221                        $theme_changed = true;
     222        }
     223
     224        if ( isset ( $current_theme->response ) && is_array( $current_theme->response ) ) {
     225                foreach ( $current_theme->response as $slug => $update_details ) {
     226                        if ( ! isset($checked[ $slug ]) ) {
     227                                $theme_changed = true;
     228                                break;
     229                        }
     230                }
     231        }
     232
     233        if( $time_not_changed && !$theme_changed )
    205234                return false;
    206235
    207236        // Update last_checked for current to prevent multiple blocking requests if request hangs
     
    210239
    211240        $current_theme->template = get_option( 'template' );
    212241
    213         $themes = array( );
    214         $themes['current_theme'] = (array) $current_theme;
    215         foreach( (array) $installed_themes as $theme_title => $theme ) {
    216                 $themes[$theme['Stylesheet']] = array( );
    217 
    218                 foreach( (array) $theme as $key => $value ) {
    219                         $themes[$theme['Stylesheet']][$key] = $value;
    220                 }
    221         }
    222 
    223242        $options = array(
    224243                'timeout'               => 3,
    225244                'body'                  => array( 'themes' => serialize( $themes ) ),
     
    235254                return false;
    236255
    237256        $response = unserialize( $raw_response['body'] );
    238         if( $response )
     257        if( $response ) {
     258                $new_option->checked = $checked;
    239259                $new_option->response = $response;
     260        }
    240261
    241262        set_transient( 'update_themes', $new_option );
    242263}