Ticket #22704: 22704-reactivate-plugins.patch
| File 22704-reactivate-plugins.patch, 1.9 KB (added by , 12 years ago) |
|---|
-
wp-admin/includes/class-wp-upgrader.php
482 482 483 483 add_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade'), 10, 2); 484 484 add_filter('upgrader_clear_destination', array($this, 'delete_old_plugin'), 10, 4); 485 add_filter( 'upgrader_post_install', array( $this, 'activate_plugin_after_upgrade' ), 10, 3 ); 485 486 //'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. 486 487 487 488 $this->run( array( … … 497 498 // Cleanup our hooks, in case something else does a upgrade on this connection. 498 499 remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); 499 500 remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); 501 remove_filter( 'upgrader_post_install', array( $this, 'activate_plugin_after_upgrade' ) ); 500 502 501 503 if ( ! $this->result || is_wp_error($this->result) ) 502 504 return $this->result; … … 660 662 } 661 663 } 662 664 665 /** 666 * Re-activate a plugin after it's been upgraded 667 * @param bool $return 668 * @param array $plugin 669 * @return null|WP_Error 670 */ 671 function activate_plugin_after_upgrade( $return, $plugin ) { 672 $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; 673 if ( empty( $plugin ) ) 674 return new WP_Error( 'bad_request', $this->strings['bad_request'] ); 675 676 if ( is_plugin_active( $plugin ) ) 677 return $return; 678 679 return activate_plugin( $plugin, '', false, true ); 680 } 681 663 682 //Hooked to upgrade_clear_destination 664 683 function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 665 684 global $wp_filesystem;