Make WordPress Core

Changeset 12097


Ignore:
Timestamp:
10/23/2009 09:49:12 PM (15 years ago)
Author:
ryan
Message:

Plugin bulk upgrade rough in. see #10973

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r11930 r12097  
    355355
    356356    var $result;
     357    var $bulk = true;
    357358
    358359    function upgrade_strings() {
     
    434435        // Force refresh of plugin update information
    435436        delete_transient('update_plugins');
     437    }
     438
     439    function bulk_upgrade($plugins) {
     440
     441        $this->init();
     442        $this->bulk = true;
     443        $this->upgrade_strings();
     444
     445        $current = get_transient( 'update_plugins' );
     446
     447        add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);
     448        add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4);
     449
     450        foreach ( $plugins as $plugin ) {
     451            if ( !isset( $current->response[ $plugin ] ) ) {
     452                $this->skin->set_result(false);
     453                $this->skin->error('up_to_date');
     454                $this->skin->after();
     455                $results[$plugin] = false;
     456                continue;
     457            }
     458
     459            // Get the URL to the zip file
     460            $r = $current->response[ $plugin ];
     461
     462            $this->skin->plugin_active = is_plugin_active($plugin);
     463
     464            $result = $this->run(array(
     465                        'package' => $r->package,
     466                        'destination' => WP_PLUGIN_DIR,
     467                        'clear_destination' => true,
     468                        'clear_working' => true,
     469                        'hook_extra' => array(
     470                                    'plugin' => $plugin
     471                        )
     472                    ));
     473               
     474            $results[$plugin] = $this->result;
     475
     476            // Prevent credentials auth screen from displaying multiple times
     477            if ( false === $result )
     478                break;
     479        }
     480
     481        //Cleanup our hooks, incase something else does a upgrade on this connection.
     482        remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));
     483        remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'));
     484
     485        // Force refresh of plugin update information
     486        delete_transient('update_plugins');
     487
     488        return $results;
    436489    }
    437490
     
    849902            $this->feedback('<strong>' . __('Actions:') . '</strong> ' . implode(' | ', (array)$update_actions));
    850903    }
     904
     905    function footer() {
     906        if ( $this->upgrader->bulk )
     907            return;
     908
     909        echo '</div>';
     910    }
    851911}
    852912
  • trunk/wp-admin/update-core.php

    r12093 r12097  
    286286}
    287287
     288function no_update_actions($actions) {
     289    return '';
     290}
     291
    288292function do_plugin_upgrade() {
    289293    include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
    290294
    291     $plugins = (array) $_POST['checked'];
    292     $url = 'update-core.php';
    293 
    294     foreach ( $plugins as $plugin ) {
    295         $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
    296         $upgrader->upgrade($plugin);       
    297     }
     295    if ( isset($_GET['plugins']) ) {
     296        $plugins = explode(',', $_GET['plugins']);
     297    } else {
     298        $plugins = (array) $_POST['checked'];
     299    }
     300    $url = 'update-core.php?action=do-plugin-upgrade&amp;plugins=' . urlencode(join(',', $plugins));
     301    $title = __('Upgrade Plugins');
     302    $nonce = 'upgrade-core';
     303    add_filter('update_plugin_complete_actions', 'no_update_actions');
     304
     305    $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact('title', 'nonce', 'url', 'plugin') ) );
     306    $upgrader->bulk_upgrade($plugins);
    298307}
    299308
Note: See TracChangeset for help on using the changeset viewer.