# deactivate_plugins()

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

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

## Сигнатура

```php
deactivate_plugins( string|string[] $plugins, bool $silent = false, bool|null $network_wide = null )
```

## Описание

Хук деактивации отключается механизмом обновления плагинов с помощью параметра $silent.

## Параметры

- `$plugins` `string|string[]` — обязательный. Один плагин или список плагинов для деактивации.
- `$silent` `bool` — необязательный, по умолчанию `false`. Предотвратить вызов хуков деактивации.
- `$network_wide` `bool|null` — необязательный, по умолчанию `null`. Деактивировать ли плагин для всех сайтов сети.
  
  Значение null деактивирует плагины и для сети, и для текущего сайта. Только для Multisite.

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

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

```php
function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
	if ( is_multisite() ) {
		$network_current = get_site_option( 'active_sitewide_plugins', array() );
	}
	$current    = get_option( 'active_plugins', array() );
	$do_blog    = false;
	$do_network = false;

	foreach ( (array) $plugins as $plugin ) {
		$plugin = plugin_basename( trim( $plugin ) );
		if ( ! is_plugin_active( $plugin ) ) {
			continue;
		}

		$network_deactivating = ( false !== $network_wide ) && is_plugin_active_for_network( $plugin );

		if ( ! $silent ) {
			/**
			 * Fires before a plugin is deactivated.
			 *
			 * If a plugin is silently deactivated (such as during an update),
			 * this hook does not fire.
			 *
			 * @since 2.9.0
			 *
			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
			 *                                     or just the current site. Multisite only. Default false.
			 */
			do_action( 'deactivate_plugin', $plugin, $network_deactivating );
		}

		if ( false !== $network_wide ) {
			if ( is_plugin_active_for_network( $plugin ) ) {
				$do_network = true;
				unset( $network_current[ $plugin ] );
			} elseif ( $network_wide ) {
				continue;
			}
		}

		if ( true !== $network_wide ) {
			$key = array_search( $plugin, $current, true );
			if ( false !== $key ) {
				$do_blog = true;
				unset( $current[ $key ] );
			}
		}

		if ( $do_blog && wp_is_recovery_mode() ) {
			list( $extension ) = explode( '/', $plugin );
			wp_paused_plugins()->delete( $extension );
		}

		if ( ! $silent ) {
			/**
			 * Fires as a specific plugin is being deactivated.
			 *
			 * This hook is the "deactivation" hook used internally by register_deactivation_hook().
			 * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
			 *
			 * If a plugin is silently deactivated (such as during an update), this hook does not fire.
			 *
			 * @since 2.0.0
			 *
			 * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
			 *                                   or just the current site. Multisite only. Default false.
			 */
			do_action( "deactivate_{$plugin}", $network_deactivating );

			/**
			 * Fires after a plugin is deactivated.
			 *
			 * If a plugin is silently deactivated (such as during an update),
			 * this hook does not fire.
			 *
			 * @since 2.9.0
			 *
			 * @param string $plugin               Path to the plugin file relative to the plugins directory.
			 * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
			 *                                     or just the current site. Multisite only. Default false.
			 */
			do_action( 'deactivated_plugin', $plugin, $network_deactivating );
		}
	}

	if ( $do_blog ) {
		update_option( 'active_plugins', $current );
	}
	if ( $do_network ) {
		update_site_option( 'active_sitewide_plugins', $network_current );
	}
}
```

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

- 2.5.0 — Introduced.

## Связанные

Использует: [`wp_is_recovery_mode`](https://chugunov.pro/api-wordpress/functions/wp_is_recovery_mode/), [`wp_paused_plugins`](https://chugunov.pro/api-wordpress/functions/wp_paused_plugins/), [`is_plugin_active`](https://chugunov.pro/api-wordpress/functions/is_plugin_active/), [`is_plugin_active_for_network`](https://chugunov.pro/api-wordpress/functions/is_plugin_active_for_network/), [`plugin_basename`](https://chugunov.pro/api-wordpress/functions/plugin_basename/), [`update_site_option`](https://chugunov.pro/api-wordpress/functions/update_site_option/), [`is_multisite`](https://chugunov.pro/api-wordpress/functions/is_multisite/), [`do_action`](https://chugunov.pro/api-wordpress/functions/do_action/), [`get_site_option`](https://chugunov.pro/api-wordpress/functions/get_site_option/), [`update_option`](https://chugunov.pro/api-wordpress/functions/update_option/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: `WP_REST_Plugins_Controller::handle_plugin_status`, `Plugin_Upgrader::deactivate_plugin_before_upgrade`, [`validate_active_plugins`](https://chugunov.pro/api-wordpress/functions/validate_active_plugins/).

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