is_uninstallable_plugin() WordPress Function

The is_uninstallable_plugin() function is used to check if a plugin is uninstallable. This function is useful for checking if a plugin is uninstallable before attempting to uninstall it.

is_uninstallable_plugin( string $plugin ) #

Determines whether the plugin can be uninstalled.


Parameters

$plugin

(string)(Required)Path to the plugin file relative to the plugins directory.


Top ↑

Return

(bool) Whether plugin can be uninstalled.


Top ↑

Source

File: wp-admin/includes/plugin.php

function is_uninstallable_plugin( $plugin ) {
	$file = plugin_basename( $plugin );

	$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
	if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) {
		return true;
	}

	return false;
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.