WordPress.org

Make WordPress Core

Ticket #14915: class-wp-upgrader.15646.diff

File class-wp-upgrader.15646.diff, 2.5 KB (added by joelhardi, 4 years ago)

patch deleting deactivation/activation on plugin upgrade

  • class-wp-upgrader.php

     
    422422                // Get the URL to the zip file 
    423423                $r = $current->response[ $plugin ]; 
    424424 
    425                 add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2); 
    426425                add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4); 
    427426                //'source_selection' => array(&$this, 'source_selection'), //theres a track ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. 
    428427 
     
    437436                                )); 
    438437 
    439438                // Cleanup our hooks, incase something else does a upgrade on this connection. 
    440                 remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade')); 
    441439                remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin')); 
    442440 
    443441                if ( ! $this->result || is_wp_error($this->result) ) 
     
    546544                return $this->result['destination_name'] . '/' . $pluginfiles[0]; 
    547545        } 
    548546 
    549         //Hooked to pre_install 
    550         function deactivate_plugin_before_upgrade($return, $plugin) { 
    551  
    552                 if ( is_wp_error($return) ) //Bypass. 
    553                         return $return; 
    554  
    555                 $plugin = isset($plugin['plugin']) ? $plugin['plugin'] : ''; 
    556                 if ( empty($plugin) ) 
    557                         return new WP_Error('bad_request', $this->strings['bad_request']); 
    558  
    559                 if ( is_plugin_active($plugin) ) { 
    560                         $this->skin->feedback('deactivate_plugin'); 
    561                         //Deactivate the plugin silently, Prevent deactivation hooks from running. 
    562                         deactivate_plugins($plugin, true); 
    563                 } 
    564         } 
    565  
    566547        //Hooked to upgrade_clear_destination 
    567548        function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 
    568549                global $wp_filesystem; 
     
    10301011 
    10311012        function after() { 
    10321013                $this->plugin = $this->upgrader->plugin_info(); 
    1033                 if ( !empty($this->plugin) && !is_wp_error($this->result) && $this->plugin_active ){ 
    1034                         show_message(__('Reactivating the plugin…')); 
    1035                         echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) .'"></iframe>'; 
    1036                 } 
    10371014 
    10381015                $update_actions =  array( 
    10391016                        '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>',