is_uninstallable_plugin( string $plugin ): bool

In this article

Determines whether the plugin can be uninstalled.

Parameters

$pluginstringrequired
Path to the plugin file relative to the plugins directory.

Return

bool Whether plugin can be uninstalled.

Source

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;
}

Changelog

VersionDescription
2.7.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.