Ticket #12754: register_uninstall_hook.diff
| File register_uninstall_hook.diff, 1.7 KB (added by scribu, 3 years ago) |
|---|
-
wp-includes/plugin.php
661 661 * @param callback $callback The callback to run when the hook is called. 662 662 */ 663 663 function register_uninstall_hook($file, $callback) { 664 // The option should not be autoloaded, because it is not needed in most 665 // cases. Emphasis should be put on using the 'uninstall.php' way of 666 // uninstalling the plugin. 664 $file = plugin_basename($file); 665 667 666 $uninstallable_plugins = (array) get_option('uninstall_plugins'); 668 $uninstallable_plugins[ plugin_basename($file)] = $callback;667 $uninstallable_plugins[$file] = true; 669 668 update_option('uninstall_plugins', $uninstallable_plugins); 669 670 add_action('uninstall_' . $file, $callback); 670 671 } 671 672 672 673 /** -
wp-admin/includes/plugin.php
479 479 $output = ob_get_clean(); 480 480 return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output); 481 481 } 482 do_action( 'activate_plugin', trim( $plugin) );483 482 if ( $network_wide ) { 484 483 $current[$plugin] = time(); 485 484 update_site_option( 'active_sitewide_plugins', $current ); … … 776 775 } 777 776 778 777 if ( isset( $uninstallable_plugins[$file] ) ) { 779 $callable = $uninstallable_plugins[$file];780 778 unset($uninstallable_plugins[$file]); 781 779 update_option('uninstall_plugins', $uninstallable_plugins); 782 780 unset($uninstallable_plugins); 783 781 784 782 include WP_PLUGIN_DIR . '/' . $file; 785 783 786 add_action( 'uninstall_' . $file, $callable );787 784 do_action( 'uninstall_' . $file ); 788 785 } 789 786 }
