Created
January 25, 2013 17:51
-
-
Save ChuckMac/4636464 to your computer and use it in GitHub Desktop.
WordPress plugin depency check. Check if another plugin is installed before allowing yours to be installed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Activation Class | |
**/ | |
if ( ! class_exists( 'WC_CPInstallCheck' ) ) { | |
class WC_CPInstallCheck { | |
static function install() { | |
/** | |
* Check if WooCommerce & Cubepoints are active | |
**/ | |
if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || | |
!in_array( 'cubepoints/cubepoints.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
// Deactivate the plugin | |
deactivate_plugins(__FILE__); | |
// Throw an error in the wordpress admin console | |
$error_message = __('This plugin requires <a href="http://wordpress.org/extend/plugins/woocommerce/">WooCommerce</a> & <a href="http://wordpress.org/extend/plugins/cubepoints/">Cubepoints</a> plugins to be active!', 'woocommerce'); | |
die($error_message); | |
} | |
} | |
} | |
} | |
register_activation_hook( __FILE__, array('WC_CPInstallCheck', 'install') ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it also shows error