From ff31cebbfd4966602e7899f2df575b60f1478f04 Mon Sep 17 00:00:00 2001 From: dd32 Date: Tue, 25 May 2010 13:57:06 +0000 Subject: [PATCH] Add Actions to the end of Bulk upgrades; Remove Spinners and instead show the individual upgrade steps (Then hidden upon completion for bulk upgrades). See #11232 git-svn-id: http://svn.automattic.com/wordpress/trunk@14879 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-upgrader.php | 67 +++++++++++++++++++------ 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index 911cc740b7..380afa9ef8 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -466,7 +466,8 @@ class Plugin_Upgrader extends WP_Upgrader { return false; } - $this->skin->feedback('bulk_upgrade_start'); + $this->skin->bulk_header(); + $this->maintenance_mode(true); $results = array(); @@ -510,7 +511,8 @@ class Plugin_Upgrader extends WP_Upgrader { } //end foreach $plugins $this->maintenance_mode(false); - $this->skin->feedback('bulk_upgrade_end'); + + $this->skin->bulk_footer(); $this->skin->footer(); @@ -708,7 +710,8 @@ class Theme_Upgrader extends WP_Upgrader { return false; } - $this->skin->feedback('bulk_upgrade_start'); + $this->skin->bulk_header(); + $this->maintenance_mode(true); $results = array(); @@ -752,7 +755,9 @@ class Theme_Upgrader extends WP_Upgrader { } //end foreach $plugins $this->maintenance_mode(false); - $this->skin->feedback('bulk_upgrade_end'); + + $this->skin->bulk_footer(); + $this->skin->footer(); // Cleanup our hooks, incase something else does a upgrade on this connection. @@ -1087,6 +1092,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { echo "$string
\n"; else echo "

$string

\n"; + $this->flush_output(); } function header() { @@ -1109,14 +1115,20 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { } $this->error = implode(', ', $messages); } - echo ''; + } + + function bulk_header() { + $this->feedback('bulk_upgrade_start'); + } + + function bulk_footer() { + $this->feedback('bulk_upgrade_end'); } function before($title = '') { $this->in_loop = true; - printf( '

' . $this->upgrader->strings['skin_before_update_header'] . '

', $title, $this->upgrader->update_current, $this->upgrader->update_count); - echo ''; - echo '

'; + printf( '

' . $this->upgrader->strings['skin_before_update_header'] . '

', $title, $this->upgrader->update_current, $this->upgrader->update_count); + echo '

'; $this->flush_output(); } @@ -1131,9 +1143,14 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin { echo ''; } if ( !empty($this->result) && !is_wp_error($this->result) ) { - echo '

' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '

'; - echo ''; + echo '

' . sprintf($this->upgrader->strings['skin_update_successful'], $title, 'jQuery(\'#progress-' . esc_js($this->upgrader->update_current) . '\').toggle();jQuery(\'span\', this).toggle(); return false;') . '

'; + + if ( $this->upgrader->update_count > 1 ) // Only hide the update steps if multiple items are being updated. + echo ''; + else + echo ''; } + $this->reset(); $this->flush_output(); } @@ -1167,6 +1184,17 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin { function after() { parent::after($this->plugin_info['Title']); } + function bulk_footer() { + parent::bulk_footer(); + $update_actions = array( + 'plugins_page' => '' . __('Return to Plugins page') . '', + 'updates_page' => '' . __('Return to WordPress Updates') . '' + ); + + $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info); + if ( ! empty($update_actions) ) + $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + } } class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { @@ -1187,6 +1215,17 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin { function after() { parent::after($this->theme_info['Name']); } + function bulk_footer() { + parent::bulk_footer(); + $update_actions = array( + 'themes_page' => '' . __('Return to Themes page') . '', + 'updates_page' => '' . __('Return to WordPress Updates') . '' + ); + + $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info); + if ( ! empty($update_actions) ) + $this->feedback('' . __('Actions:') . ' ' . implode(' | ', (array)$update_actions)); + } } /** @@ -1341,6 +1380,7 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { function after() { + $update_actions = array(); if ( !empty($this->upgrader->result['destination_name']) && ($theme_info = $this->upgrader->theme_info()) && !empty($theme_info) ) { @@ -1352,10 +1392,9 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin { $preview_link = htmlspecialchars( add_query_arg( array('preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'TB_iframe' => 'true' ), trailingslashit(esc_url(get_option('home'))) ) ); $activate_link = wp_nonce_url("themes.php?action=activate&template=" . urlencode($template) . "&stylesheet=" . urlencode($stylesheet), 'switch-theme_' . $template); - $update_actions = array( - 'preview' => '' . __('Preview') . '', - 'activate' => '' . __('Activate') . '', - ); + $update_actions['preview'] = '' . __('Preview') . ''; + $update_actions['activate'] = '' . __('Activate') . ''; + if ( ( ! $this->result || is_wp_error($this->result) ) || $stylesheet == get_stylesheet() ) unset($update_actions['preview'], $update_actions['activate']); }