Ticket #14915: class-wp-upgrader.15646.2.diff
File class-wp-upgrader.15646.2.diff, 3.4 KB (added by , 13 years ago) |
---|
-
class-wp-upgrader.php
422 423 // Get the URL to the zip file 423 424 $r = $current->response[ $plugin ]; 424 425 425 add_filter('upgrader_pre_install', array(&$this, 'deactivate_plugin_before_upgrade'), 10, 2);426 426 add_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin'), 10, 4); 427 427 //'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 428 … … 437 437 )); 438 438 439 439 // 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 440 remove_filter('upgrader_clear_destination', array(&$this, 'delete_old_plugin')); 442 441 443 442 if ( ! $this->result || is_wp_error($this->result) ) … … 546 545 return $this->result['destination_name'] . '/' . $pluginfiles[0]; 547 546 } 548 547 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 548 //Hooked to upgrade_clear_destination 567 549 function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 568 550 global $wp_filesystem; … … 1030 1012 1031 1013 function after() { 1032 1014 $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 1015 1038 1016 $update_actions = array( 1039 '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>',1040 1017 'plugins_page' => '<a href="' . admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>' 1041 1018 ); 1042 if ( $this->plugin_active ) 1043 unset( $update_actions['activate_plugin'] ); 1044 if ( ! $this->result || is_wp_error($this->result) ) 1045 unset( $update_actions['activate_plugin'] ); 1019 if ( !$this->plugin_active && !is_wp_error($this->result) && $this->result ) 1020 $update_actions[ '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>'; 1046 1021 1047 1022 $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin); 1048 1023 if ( ! empty($update_actions) )