Automattic\WooCommerce\Utilities

PluginUtil::is_woocommerce_aware_plugin()publicWC 1.0

Check if a plugin is WooCommerce aware.

{} Это метод класса: PluginUtil{}

Хуков нет.

Возвращает

true|false. True if the plugin exists and is WooCommerce aware.

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

$PluginUtil = new PluginUtil();
$PluginUtil->is_woocommerce_aware_plugin( $plugin_file_or_data ): bool;
$plugin_file_or_data(строка|массив) (обязательный)
Plugin id (path/file.php) or plugin data (as returned by get_plugins).

Код PluginUtil::is_woocommerce_aware_plugin() WC 7.1.0

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 '' !== ArrayUtil::get_value_or_default( $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' );
	}
}