Yoast\WP\SEO\Services\Importing

Conflicting_Plugins_Service::ignore_deactivating_plugin()protectedYoast 1.0

While deactivating a plugin, we should ignore the plugin currently being deactivated.

Метод класса: Conflicting_Plugins_Service{}

Хуков нет.

Возвращает

Массив. The remaining active plugins.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->ignore_deactivating_plugin( $all_active_plugins );
$all_active_plugins(массив) (обязательный)
All plugins currently loaded by WordPress.

Код Conflicting_Plugins_Service::ignore_deactivating_plugin() Yoast 19.11

protected function ignore_deactivating_plugin( $all_active_plugins ) {
	if ( isset( $_GET['action'] ) && isset( $_GET['plugin'] ) && \filter_var( \wp_unslash( $_GET['action'] ) ) === 'deactivate' ) {
		$deactivated_plugin = \filter_var( \wp_unslash( $_GET['plugin'] ) );

		\check_admin_referer( 'deactivate-plugin_' . $deactivated_plugin );

		$key_to_remove = \array_search( $deactivated_plugin, $all_active_plugins, true );
		if ( $key_to_remove !== false ) {
			unset( $all_active_plugins[ $key_to_remove ] );
		}
	}

	return $all_active_plugins;
}