Index: /trunk/wp-admin/includes/class-wp-upgrader.php =================================================================== --- /trunk/wp-admin/includes/class-wp-upgrader.php (revision 13685) +++ /trunk/wp-admin/includes/class-wp-upgrader.php (revision 13686) @@ -470,8 +470,8 @@ $results = array(); - $this->plugin_count = count($plugins); - $this->plugin_current = 0; + $this->update_count = count($plugins); + $this->update_current = 0; foreach ( $plugins as $plugin ) { - $this->plugin_current++; + $this->update_current++; $this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true); @@ -683,4 +683,80 @@ } + function bulk_upgrade($themes) { + + $this->init(); + $this->bulk = true; + $this->upgrade_strings(); + + $current = get_site_transient( 'update_themes' ); + + add_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); + add_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); + add_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); + + $this->skin->header(); + + // Connect to the Filesystem first. + $res = $this->fs_connect( array(WP_CONTENT_DIR) ); + if ( ! $res ) { + $this->skin->footer(); + return false; + } + + $this->maintenance_mode(true); + + $results = array(); + + $this->update_count = count($themes); + $this->update_current = 0; + foreach ( $themes as $theme ) { + $this->update_current++; + + if ( !isset( $current->response[ $theme ] ) ) { + $this->skin->set_result(false); + $this->skin->before(); + $this->skin->error('up_to_date'); + $this->skin->after(); + $results[$theme] = false; + continue; + } + + $this->skin->theme_info = $this->theme_info($theme); + + // Get the URL to the zip file + $r = $current->response[ $theme ]; + + $options = array( + 'package' => $r['package'], + 'destination' => WP_CONTENT_DIR . '/themes', + 'clear_destination' => true, + 'clear_working' => true, + 'hook_extra' => array( + 'theme' => $theme + ) + ); + + $result = $this->run($options); + + $results[$theme] = $this->result; + + // Prevent credentials auth screen from displaying multiple times + if ( false === $result ) + break; + } //end foreach $plugins + $this->maintenance_mode(false); + $this->skin->footer(); + + // Cleanup our hooks, incase something else does a upgrade on this connection. + remove_filter('upgrader_pre_install', array(&$this, 'current_before'), 10, 2); + remove_filter('upgrader_post_install', array(&$this, 'current_after'), 10, 2); + remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_theme'), 10, 4); + + // Force refresh of theme update information + delete_site_transient('update_themes'); + + return $results; + } + function current_before($return, $theme) { @@ -693,5 +769,6 @@ return $return; //Change to maintainence mode now. - $this->maintenance_mode(true); + if ( ! $this->bulk ) + $this->maintenance_mode(true); return $return; @@ -715,5 +792,6 @@ //Time to remove maintainence mode - $this->maintenance_mode(false); + if ( ! $this->bulk ) + $this->maintenance_mode(false); return $return; } @@ -734,8 +812,13 @@ } - function theme_info() { - if ( empty($this->result['destination_name']) ) - return false; - return get_theme_data(WP_CONTENT_DIR . '/themes/' . $this->result['destination_name'] . '/style.css'); + function theme_info($theme = null) { + + if ( empty($theme) ) { + if ( !empty($this->result['destination_name']) ) + $theme = $this->result['destination_name']; + else + return false; + } + return get_theme_data(WP_CONTENT_DIR . '/themes/' . $theme . '/style.css'); } @@ -827,5 +910,10 @@ if ( is_object($upgrader) ) $this->upgrader =& $upgrader; - } + $this->add_strings(); + } + + function add_strings() { + } + function set_result($result) { $this->result = $result; @@ -950,9 +1038,9 @@ * @since 3.0 */ -class Bulk_Plugin_Upgrader_Skin extends WP_Upgrader_Skin { +class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { var $in_loop = false; var $error = false; - function Plugin_Upgrader_Skin($args = array()) { + function Bulk_Upgrader_Skin($args = array()) { return $this->__construct($args); } @@ -964,5 +1052,11 @@ parent::__construct($args); } - + + function add_strings() { + $this->upgrader->strings['skin_update_failed_error'] = __('An error occured while updating %1$s: %2$s.'); + $this->upgrader->strings['skin_update_failed'] = __('The update of %1$s failed.'); + $this->upgrader->strings['skin_update_successful'] = __('%1$s updated successfully. See Details.'); + } + function feedback($string) { if ( isset( $this->upgrader->strings[$string] ) ) @@ -1005,22 +1099,23 @@ } - function before() { + function before($title = '') { $this->in_loop = true; - printf( '