Advertisements

uninstall_plugin

Definition:
function uninstall_plugin($plugin) {}

Uninstall a single plugin.
Calls the uninstall hook, if it is available.

Parameters

  • string $plugin: Relative plugin path from Plugin Directory.

Defined actions

  • uninstall_’.$file
    do_action( 'uninstall_' . $file );

Source code

function uninstall_plugin($plugin) {

	$file = plugin_basename($plugin);



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

	if ( file_exists( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' ) ) {

		if ( isset( $uninstallable_plugins[$file] ) ) {

			unset($uninstallable_plugins[$file]);

			update_option('uninstall_plugins', $uninstallable_plugins);

		}

		unset($uninstallable_plugins);



		define('WP_UNINSTALL_PLUGIN', $file);

		include WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php';



		return true;

	}



	if ( isset( $uninstallable_plugins[$file] ) ) {

		$callable = $uninstallable_plugins[$file];

		unset($uninstallable_plugins[$file]);

		update_option('uninstall_plugins', $uninstallable_plugins);

		unset($uninstallable_plugins);



		include WP_PLUGIN_DIR . '/' . $file;



		add_action( 'uninstall_' . $file, $callable );

		do_action( 'uninstall_' . $file );

	}

}

3127

Advertisements

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:

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: