Automattic\WooCommerce\Internal\Utilities
PluginInstaller::woocommerce_is_active_in_current_site
Check if WooCommerce is installed and active in the current blog. This is useful for multisite installs when a blog other than the one running this code is selected with 'switch_to_blog'.
Method of the class: PluginInstaller{}
No Hooks.
Returns
true|false. True if WooCommerce is installed and active in the current blog, false otherwise.
Usage
$result = PluginInstaller::woocommerce_is_active_in_current_site(): bool;
PluginInstaller::woocommerce_is_active_in_current_site() PluginInstaller::woocommerce is active in current site code WC 10.3.5
private static function woocommerce_is_active_in_current_site(): bool {
$active_valid_plugins = wc_get_container()->get( PluginUtil::class )->get_all_active_valid_plugins();
return ! empty(
array_filter(
$active_valid_plugins,
fn( $plugin ) => substr_compare( $plugin, '/woocommerce.php', -strlen( '/woocommerce.php' ) ) === 0
)
);
}