function register_uninstall_hook( $file, $callback ) {}

Set the uninstallation hook for a plugin.
Registers the uninstall hook that will be called when the user clicks on the uninstall link that calls for the plugin to uninstall itself. The link won’t be active unless the plugin hooks into the action.


  • string $file
  • callback $callback: The callback to run when the hook is called. Must be a static method or function.

Source code

function register_uninstall_hook( $file, $callback ) {

	if ( is_array( $callback ) && is_object( $callback[0] ) ) {

		_doing_it_wrong( __FUNCTION__, __( 'Only a static class method or function can be used in an uninstall hook.' ), '3.1' );



	// The option should not be autoloaded, because it is not needed in most

	// cases. Emphasis should be put on using the 'uninstall.php' way of

	// uninstalling the plugin.

	$uninstallable_plugins = (array) get_option('uninstall_plugins');

	$uninstallable_plugins[plugin_basename($file)] = $callback;

	update_option('uninstall_plugins', $uninstallable_plugins);



No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: