Automattic\WooCommerce\Admin

PluginsHelper::get_active_plugin_slugs()public staticWC 1.0

Get an array of active plugin slugs.

The list will include both network active and site active plugins.

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

Хуков нет.

Возвращает

Массив. The list of active plugin slugs.

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

$result = PluginsHelper::get_active_plugin_slugs();

Код PluginsHelper::get_active_plugin_slugs() WC 9.8.2

public static function get_active_plugin_slugs() {
	return array_unique(
		array_map(
			function ( $absolute_path ) {
				// Make the path relative to the plugins directory.
				$plugin_path = str_replace( WP_PLUGIN_DIR . '/', '', $absolute_path );

				// Split the path to get the plugin slug (aka the directory name).
				$path_parts = explode( '/', $plugin_path );

				return $path_parts[0];
			},
			// Use this method as it is the most bulletproof way to get the active plugins.
			wc_get_container()->get( PluginUtil::class )->get_all_active_valid_plugins()
		)
	);
}