Ticket #14915: class-wp-upgrader.15646.diff
File class-wp-upgrader.15646.diff, 2.5 KB (added by , 13 years ago) |
---|
-
class-wp-upgrader.php
422 422 // Get the URL to the zip file 423 423 $r = $current->response[ $plugin ]; 424 424 425 add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);426 425 add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4); 427 426 //'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. 428 427 … … 437 436 )); 438 437 439 438 // Cleanup our hooks, incase something else does a upgrade on this connection. 440 remove_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'));441 439 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin')); 442 440 443 441 if ( ! $this->result || is_wp_error($this->result) ) … … 546 544 return $this->result['destination_name'] . '/' . $pluginfiles[0]; 547 545 } 548 546 549 //Hooked to pre_install550 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 566 547 //Hooked to upgrade_clear_destination 567 548 function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 568 549 global $wp_filesystem; … … 1030 1011 1031 1012 function after() { 1032 1013 $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 }1037 1014 1038 1015 $update_actions = array( 1039 1016 'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . $this->plugin, 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',