is_uninstallable_plugin

The timeline below displays how wordpress function is_uninstallable_plugin has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Determines whether the plugin can be uninstalled.
 *
 * @since 2.7.0
 *
 * @param string $plugin Path to the plugin file relative to the plugins directory.
 * @return bool Whether plugin can be uninstalled.
 */
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;
}

WordPress Version: 5.1

/**
 * Whether the plugin can be uninstalled.
 *
 * @since 2.7.0
 *
 * @param string $plugin Path to the plugin file relative to the plugins directory.
 * @return bool Whether plugin can be uninstalled.
 */
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;
}

WordPress Version: 4.8

/**
 * Whether the plugin can be uninstalled.
 *
 * @since 2.7.0
 *
 * @param string $plugin Path to the main plugin file from plugins directory.
 * @return bool Whether plugin can be uninstalled.
 */
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;
}

WordPress Version: 3.7

/**
 * Whether the plugin can be uninstalled.
 *
 * @since 2.7.0
 *
 * @param string $plugin Plugin path to check.
 * @return bool Whether plugin can be uninstalled.
 */
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;
}