# uninstall_plugin()

URL: https://chugunov.pro/api-wordpress/functions/uninstall_plugin/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.7.0.

## Сигнатура

```php
uninstall_plugin( string $plugin ): true|void
```

## Описание

Вызывает хук удаления, если он доступен.

## Параметры

- `$plugin` `string` — обязательный. Путь к файлу плагина относительно каталога плагинов.

## Возвращаемое значение

`true|void`

## Исходный код

Файл: `wp-admin/includes/plugin.php:1302`

```php
function uninstall_plugin( $plugin ) {
	$file = plugin_basename( $plugin );

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

	/**
	 * 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.
	 */
	do_action( 'pre_uninstall_plugin', $plugin, $uninstallable_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 );

		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
		include_once 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 );

		wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
		include_once WP_PLUGIN_DIR . '/' . $file;

		add_action( "uninstall_{$file}", $callable );

		/**
		 * Fires in uninstall_plugin() once the plugin has been uninstalled.
		 *
		 * The action concatenates the 'uninstall_' prefix with the basename of the
		 * plugin passed to uninstall_plugin() to create a dynamically-named action.
		 *
		 * @since 2.7.0
		 */
		do_action( "uninstall_{$file}" );
	}
}
```

## История изменений

- 2.7.0 — Introduced.

## Связанные

Использует: [`plugin_basename`](https://chugunov.pro/api-wordpress/functions/plugin_basename/), [`wp_register_plugin_realpath`](https://chugunov.pro/api-wordpress/functions/wp_register_plugin_realpath/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/), [`add_action`](https://chugunov.pro/api-wordpress/functions/add_action/), [`update_option`](https://chugunov.pro/api-wordpress/functions/update_option/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: [`delete_plugins`](https://chugunov.pro/api-wordpress/functions/delete_plugins/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/uninstall_plugin/
