Make WordPress Core


Ignore:
Timestamp:
04/03/2014 04:02:35 AM (12 years ago)
Author:
nacin
Message:

Background Updates: Record plugin & theme update statistics like we do for core updates.

Pass plugin/theme update objects into the Background updater for consistency with core & translations.

Merges [27905] to the 3.7 branch.

props dd32.
fixes #27633.

Location:
branches/3.7
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.7

  • branches/3.7/src/wp-admin/includes/class-wp-upgrader.php

    r27883 r27924  
    18731873                        return false;
    18741874
     1875                $upgrader_item = $item;
    18751876                switch ( $type ) {
    18761877                        case 'core':
     
    18791880                                break;
    18801881                        case 'theme':
    1881                                 $theme = wp_get_theme( $item );
     1882                                $upgrader_item = $item->theme;
     1883                                $theme = wp_get_theme( $upgrader_item );
    18821884                                $item_name = $theme->Get( 'Name' );
    18831885                                $skin->feedback( __( 'Updating theme: %s' ), $item_name );
    18841886                                break;
    18851887                        case 'plugin':
    1886                                 $plugin_data = get_plugin_data( $context . '/' . $item );
     1888                                $upgrader_item = $item->plugin;
     1889                                $plugin_data = get_plugin_data( $context . '/' . $upgrader_item );
    18871890                                $item_name = $plugin_data['Name'];
    18881891                                $skin->feedback( __( 'Updating plugin: %s' ), $item_name );
     
    18961899
    18971900                // Boom, This sites about to get a whole new splash of paint!
    1898                 $upgrade_result = $upgrader->upgrade( $item, array(
     1901                $upgrade_result = $upgrader->upgrade( $upgrader_item, array(
    18991902                        'clear_update_cache' => false,
    19001903                        'pre_check_md5'      => false, /* always use partial builds if possible for core updates */
     
    19701973                $plugin_updates = get_site_transient( 'update_plugins' );
    19711974                if ( $plugin_updates && !empty( $plugin_updates->response ) ) {
    1972                         foreach ( array_keys( $plugin_updates->response ) as $plugin ) {
     1975                        foreach ( $plugin_updates->response as $plugin ) {
    19731976                                $this->update( 'plugin', $plugin );
    19741977                        }
     
    19811984                $theme_updates = get_site_transient( 'update_themes' );
    19821985                if ( $theme_updates && !empty( $theme_updates->response ) ) {
    1983                         foreach ( array_keys( $theme_updates->response ) as $theme ) {
    1984                                 $this->update( 'theme', $theme );
     1986                        foreach ( $theme_updates->response as $theme ) {
     1987                                $this->update( 'theme', (object) $theme );
    19851988                        }
    19861989                        // Force refresh of theme update information
     
    19972000                // Clean up, and check for any pending translations
    19982001                // (Core_Upgrader checks for core updates)
    1999                 wp_update_themes();  // Check for Theme updates
    2000                 wp_update_plugins(); // Check for Plugin updates
     2002                $theme_stats = array();
     2003                if ( isset( $this->update_results['theme'] ) ) {
     2004                        foreach ( $this->update_results['theme'] as $upgrade ) {
     2005                                $theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
     2006                        }
     2007                }
     2008                wp_update_themes( $theme_stats );  // Check for Theme updates
     2009
     2010                $plugin_stats = array();
     2011                if ( isset( $this->update_results['plugin'] ) ) {
     2012                        foreach ( $this->update_results['plugin'] as $upgrade ) {
     2013                                $plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
     2014                        }
     2015                }
     2016                wp_update_plugins( $plugin_stats ); // Check for Plugin updates
    20012017
    20022018                // Finally, Process any new translations
Note: See TracChangeset for help on using the changeset viewer.