Automattic\WooCommerce\Utilities
PluginUtil::is_woocommerce_aware_plugin()
Check if a plugin is WooCommerce aware.
Method of the class: PluginUtil{}
No Hooks.
Return
true|false
. True if the plugin exists and is WooCommerce aware.
Usage
$PluginUtil = new PluginUtil(); $PluginUtil->is_woocommerce_aware_plugin( $plugin_file_or_data ): bool;
- $plugin_file_or_data(string|array) (required)
- Plugin id (path/file.php) or plugin data (as returned by get_plugins).
PluginUtil::is_woocommerce_aware_plugin() PluginUtil::is woocommerce aware plugin code WC 9.4.2
public function is_woocommerce_aware_plugin( $plugin_file_or_data ): bool { if ( is_string( $plugin_file_or_data ) ) { return in_array( $plugin_file_or_data, $this->get_woocommerce_aware_plugins(), true ); } elseif ( is_array( $plugin_file_or_data ) ) { return '' !== ( $plugin_file_or_data['WC tested up to'] ?? '' ); } else { throw new \Exception( 'is_woocommerce_aware_plugin requires a plugin name or an array of plugin data as input' ); } }