Action hook 'pre_uninstall_plugin'

in WP Core File wp-admin/includes/plugin.php at line 1302

View Source

pre_uninstall_plugin

Action Hook
Description
Fires in uninstall_plugin() immediately before the plugin is uninstalled.

Hook Information

File Location wp-admin/includes/plugin.php View on GitHub
Hook Type Action
Line Number 1302

Hook Parameters

Type Name Description
string $plugin Path to the plugin file relative to the plugins directory.
array $uninstallable_plugins Uninstallable plugins.

Usage Examples

Basic Usage
<?php
// Hook into pre_uninstall_plugin
add_action('pre_uninstall_plugin', 'my_custom_function', 10, 2);

function my_custom_function($plugin, $uninstallable_plugins) {
    // Your custom code here
}

Source Code Context

wp-admin/includes/plugin.php:1302 - How this hook is used in WordPress core
<?php
1297  	 * @since 4.5.0
1298  	 *
1299  	 * @param string $plugin                Path to the plugin file relative to the plugins directory.
1300  	 * @param array  $uninstallable_plugins Uninstallable plugins.
1301  	 */
1302  	do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_plugins );
1303  
1304  	if ( file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
1305  		if ( isset( $uninstallable_plugins[ $file ] ) ) {
1306  			unset( $uninstallable_plugins[ $file ] );
1307  			update_option( 'uninstall_plugins', $uninstallable_plugins );

PHP Documentation

<?php
/**
	 * Fires in uninstall_plugin() immediately before the plugin is uninstalled.
	 *
	 * @since 4.5.0
	 *
	 * @param string $plugin                Path to the plugin file relative to the plugins directory.
	 * @param array  $uninstallable_plugins Uninstallable plugins.
	 */
Quick Info
  • Hook Type: Action
  • Parameters: 2
  • File: wp-admin/includes/plugin.php
Related Hooks

Related hooks will be displayed here in future updates.