Put site into maintenance mode during bulk plugin upgrade. Skip plugin deactivate/activate. Add compatibility info. see #10973

git-svn-id: http://svn.automattic.com/wordpress/trunk@12157 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-11-09 18:53:21 +00:00
parent 9655ccf4d8
commit 2bf341d5d5
3 changed files with 31 additions and 7 deletions

View File

@ -432,7 +432,7 @@ class Plugin_Upgrader extends WP_Upgrader {
)
));
//Cleanup our hooks, incase something else does a upgrade on this connection.
// Cleanup our hooks, incase something else does a upgrade on this connection.
remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
@ -451,10 +451,19 @@ class Plugin_Upgrader extends WP_Upgrader {
$current = get_transient( 'update_plugins' );
add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
$this->skin->header();
// Connect to the Filesystem first.
$res = $this->fs_connect( array(WP_CONTENT_DIR, WP_PLUGIN_DIR) );
if ( ! $res ) {
$this->skin->footer();
return false;
}
$this->maintenance_mode(true);
$all = count($plugins);
$i = 1;
foreach ( $plugins as $plugin ) {
@ -492,10 +501,10 @@ class Plugin_Upgrader extends WP_Upgrader {
if ( false === $result )
break;
}
$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, 'deactivate_plugin_before_upgrade'));
// Cleanup our hooks, incase something else does a upgrade on this connection.
remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
// Force refresh of plugin update information
@ -899,11 +908,15 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
}
function after() {
if ( $this->upgrader->bulk )
return;
$this->plugin = $this->upgrader->plugin_info();
if( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){
show_message(__('Attempting reactivation of the plugin'));
echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>';
}
$update_actions = array(
'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Goto plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'

View File

@ -133,6 +133,11 @@ function core_upgrade_preamble() {
}
function list_plugin_updates() {
global $wp_version;
$cur_wp_version = preg_replace('/-.*$/', '', $wp_version);
require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
$plugins = get_plugin_updates();
if ( empty($plugins) )
return;
@ -160,10 +165,17 @@ function list_plugin_updates() {
<tbody class="plugins">
<?php
foreach ( (array) $plugins as $plugin_file => $plugin_data) {
$info = plugins_api('plugin_information', array('slug' => $plugin_data->update->slug ));
if ( isset($info->compatibility[$cur_wp_version][$plugin_data->update->new_version]) ) {
$compat = $info->compatibility[$cur_wp_version][$plugin_data->update->new_version];
$compat = ' ' . sprintf(__('Compatibility: %1$d%% (%2$d "works" votes out of %3$d total)'), $compat[0], $compat[2], $compat[1]);
} else {
$compat = '';
}
echo "
<tr class='active'>
<th scope='row' class='check-column'><input type='checkbox' name='checked[]' value='" . esc_attr($plugin_file) . "' /></th>
<td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You are running version %1$s. Upgrade to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . "</td>
<td class='plugin-title'><strong>{$plugin_data->Name}</strong>" . sprintf(__('You are running version %1$s. Upgrade to %2$s.'), $plugin_data->Version, $plugin_data->update->new_version) . $compat . "</td>
</tr>";
}
?>
@ -300,8 +312,6 @@ function do_plugin_upgrade() {
$url = 'update-core.php?action=do-plugin-upgrade&amp;plugins=' . urlencode(join(',', $plugins));
$title = __('Upgrade Plugins');
$nonce = 'upgrade-core';
add_filter('update_plugin_complete_actions', 'no_update_actions');
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
$upgrader->bulk_upgrade($plugins);
}

View File

@ -314,6 +314,7 @@ add_action( 'wp_version_check', 'wp_version_check' );
add_action( 'load-plugins.php', 'wp_update_plugins' );
add_action( 'load-update.php', 'wp_update_plugins' );
add_action( 'load-update-core.php', 'wp_update_plugins' );
add_action( 'admin_init', '_maybe_update_plugins' );
add_action( 'wp_update_plugins', 'wp_update_plugins' );