Skip to content

Instantly share code, notes, and snippets.

@curtismchale
Created July 9, 2014 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save curtismchale/7a319974b4c906d9f57d to your computer and use it in GitHub Desktop.
Save curtismchale/7a319974b4c906d9f57d to your computer and use it in GitHub Desktop.
<?php
// 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>
</div>
<?php
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