Automattic\WooCommerce\Utilities

PluginUtil::get_woocommerce_aware_plugins()publicWC 1.0

Get a list with the names of the WordPress plugins that are WooCommerce aware (they have a "WC tested up to" header).

Method of the class: PluginUtil{}

No Hooks.

Return

String[]. A list of plugin ids (path/file.php).

Usage

$PluginUtil = new PluginUtil();
$PluginUtil->get_woocommerce_aware_plugins( $active_only ): array;
$active_only(true|false)
True to return only active plugins, false to return all the active plugins.
Default: false

PluginUtil::get_woocommerce_aware_plugins() code WC 7.1.1

public function get_woocommerce_aware_plugins( bool $active_only = false ): array {
	if ( is_null( $this->woocommerce_aware_plugins ) ) {
		$all_plugins = $this->proxy->call_function( 'get_plugins' );

		$this->woocommerce_aware_plugins =
			array_keys(
				array_filter(
					$all_plugins,
					array( $this, 'is_woocommerce_aware_plugin' )
				)
			);

		$this->woocommerce_aware_active_plugins =
			array_values(
				array_filter(
					$this->woocommerce_aware_plugins,
					function ( $plugin_name ) {
						return $this->proxy->call_function( 'is_plugin_active', $plugin_name );
					}
				)
			);
	}

	return $active_only ? $this->woocommerce_aware_active_plugins : $this->woocommerce_aware_plugins;
}