Plugin bulk upgrade rough in. see #10973
git-svn-id: http://svn.automattic.com/wordpress/trunk@12097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
deaf8bd758
commit
4ff21e0cd3
|
@ -354,6 +354,7 @@ class WP_Upgrader {
|
||||||
class Plugin_Upgrader extends WP_Upgrader {
|
class Plugin_Upgrader extends WP_Upgrader {
|
||||||
|
|
||||||
var $result;
|
var $result;
|
||||||
|
var $bulk = true;
|
||||||
|
|
||||||
function upgrade_strings() {
|
function upgrade_strings() {
|
||||||
$this->strings['up_to_date'] = __('The plugin is at the latest version.');
|
$this->strings['up_to_date'] = __('The plugin is at the latest version.');
|
||||||
|
@ -435,6 +436,58 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||||
delete_transient('update_plugins');
|
delete_transient('update_plugins');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bulk_upgrade($plugins) {
|
||||||
|
|
||||||
|
$this->init();
|
||||||
|
$this->bulk = true;
|
||||||
|
$this->upgrade_strings();
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
foreach ( $plugins as $plugin ) {
|
||||||
|
if ( !isset( $current->response[ $plugin ] ) ) {
|
||||||
|
$this->skin->set_result(false);
|
||||||
|
$this->skin->error('up_to_date');
|
||||||
|
$this->skin->after();
|
||||||
|
$results[$plugin] = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the URL to the zip file
|
||||||
|
$r = $current->response[ $plugin ];
|
||||||
|
|
||||||
|
$this->skin->plugin_active = is_plugin_active($plugin);
|
||||||
|
|
||||||
|
$result = $this->run(array(
|
||||||
|
'package' => $r->package,
|
||||||
|
'destination' => WP_PLUGIN_DIR,
|
||||||
|
'clear_destination' => true,
|
||||||
|
'clear_working' => true,
|
||||||
|
'hook_extra' => array(
|
||||||
|
'plugin' => $plugin
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
$results[$plugin] = $this->result;
|
||||||
|
|
||||||
|
// Prevent credentials auth screen from displaying multiple times
|
||||||
|
if ( false === $result )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//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'));
|
||||||
|
|
||||||
|
// Force refresh of plugin update information
|
||||||
|
delete_transient('update_plugins');
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
//return plugin info.
|
//return plugin info.
|
||||||
function plugin_info() {
|
function plugin_info() {
|
||||||
if ( ! is_array($this->result) )
|
if ( ! is_array($this->result) )
|
||||||
|
@ -848,6 +901,13 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||||
if ( ! empty($update_actions) )
|
if ( ! empty($update_actions) )
|
||||||
$this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
|
$this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function footer() {
|
||||||
|
if ( $this->upgrader->bulk )
|
||||||
|
return;
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -285,16 +285,25 @@ function do_undismiss_core_update() {
|
||||||
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
|
wp_redirect( wp_nonce_url('update-core.php?action=upgrade-core', 'upgrade-core') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function no_update_actions($actions) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
function do_plugin_upgrade() {
|
function do_plugin_upgrade() {
|
||||||
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||||
|
|
||||||
|
if ( isset($_GET['plugins']) ) {
|
||||||
|
$plugins = explode(',', $_GET['plugins']);
|
||||||
|
} else {
|
||||||
$plugins = (array) $_POST['checked'];
|
$plugins = (array) $_POST['checked'];
|
||||||
$url = 'update-core.php';
|
|
||||||
|
|
||||||
foreach ( $plugins as $plugin ) {
|
|
||||||
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
|
|
||||||
$upgrader->upgrade($plugin);
|
|
||||||
}
|
}
|
||||||
|
$url = 'update-core.php?action=do-plugin-upgrade&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);
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
|
$action = isset($_GET['action']) ? $_GET['action'] : 'upgrade-core';
|
||||||
|
|
Loading…
Reference in New Issue