Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Theming Snippets] Query whether WooCommerce is activated
/**
* Check if WooCommerce is activated
*/
if ( ! function_exists( 'is_woocommerce_activated' ) ) {
function is_woocommerce_activated() {
if ( class_exists( 'woocommerce' ) ) { return true; } else { return false; }
}
}
@AndreiIgna
Copy link

AndreiIgna commented Mar 16, 2019

class_exists returns boolean, there's no need for IF structure

function is_woocommerce_activated() {
	return class_exists( 'woocommerce' );
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment