Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// hooked inside a class for my normal dev work
add_action( 'admin_notices', 'check_required_plugins' );
* Checks for WooCommerce and kills our plugin if it isn't active
* @uses function_exists Checks for the function given string
* @uses deactivate_plugins Deactivates plugins given string or array of plugins
* @action admin_notices Provides WordPress admin notices
* @since 1.0
* @author ME
public function check_required_plugins(){
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { ?>
<div id="message" class="error">
<p>Limit Products requires WooCommerce to be active. This plugin has been deactivated.</p>
deactivate_plugins( '/limit-products/limit-products.php' );
} // compmany team if
} // check_required_plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment