I'm creating a theme with yith woocommerce wishlist which has the following:
if( ! function_exists( 'WooCommerce' ) ){
function check_yith_enable_or_disable(){
echo do_shortcode( "[yith_wcwl_add_to_wishlist]" );
}
add_action( 'woocommerce_after_shop_loop_item', 'check_yith_enable_or_disable', 10 );
}
However this breaks the site if the yith woocommerce wishlist plugin is not activated. How can I check if the yith woocommerce wishlist plugin is activated?
Used is_plugin_active() to check plugin is active or not
Used Of
is_plugin_active()
In the Admin Area:
<?php is_plugin_active($plugin) ?>
In the front end, in a theme, etc...
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?>
<?php $plugin='plugin-directory/plugin-file.php'; ?>
<?php is_plugin_active($plugin) ?>
Return Values
True if plugin is activated, else false.
For YITH WooCommerce Wishlist in front End
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?>
<?php $plugin='yith-woocommerce-wishlist/init.php'; ?>
<?php if(is_plugin_active($plugin)){
//plugin is activated
}else{
//plugin is not activated
} ?>