Make WordPress Core


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

Plugin bulk upgrade rough in. see #10973

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.