Ticket #22704: 22704-reactivate-plugins.2.patch.diff
| File 22704-reactivate-plugins.2.patch.diff, 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 if ( is_plugin_active( $plugin ) ) 486 add_filter( 'upgrader_post_install', array( $this, 'activate_plugin_after_upgrade' ), 10, 3 ); 485 487 //'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 488 487 489 $this->run( array( … … 497 499 // Cleanup our hooks, in case something else does a upgrade on this connection. 498 500 remove_filter('upgrader_pre_install', array($this, 'deactivate_plugin_before_upgrade')); 499 501 remove_filter('upgrader_clear_destination', array($this, 'delete_old_plugin')); 502 if ( is_plugin_active( $plugin ) ) 503 remove_filter( 'upgrader_post_install', array( $this, 'activate_plugin_after_upgrade' ) ); 500 504 501 505 if ( ! $this->result || is_wp_error($this->result) ) 502 506 return $this->result; … … 660 664 } 661 665 } 662 666 667 /** 668 * Re-activate a plugin after it's been upgraded 669 * @param bool $return 670 * @param array $plugin 671 * @return null|WP_Error 672 */ 673 function activate_plugin_after_upgrade( $return, $plugin ) { 674 $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; 675 if ( empty( $plugin ) ) 676 return new WP_Error( 'bad_request', $this->strings['bad_request'] ); 677 678 if ( is_plugin_active( $plugin ) ) 679 return $return; 680 681 return activate_plugin( $plugin, '', false, true ); 682 } 683 663 684 //Hooked to upgrade_clear_destination 664 685 function delete_old_plugin($removed, $local_destination, $remote_destination, $plugin) { 665 686 global $wp_filesystem;