-
-
Save tommcfarlin/1096d100351054b84ec778a516dde2f6 to your computer and use it in GitHub Desktop.
[WordPress] Control Activation of a WooCommerce Extension
This file contains 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
<?php | |
class Extension_For_WooCommerce { | |
public function init() { | |
add_action( 'admin_init', array( $this, 'start' ) ); | |
add_action( 'admin_init', array( $this, 'stop' ) ); | |
} | |
} |
This file contains 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
<?php | |
private function woocommerce_is_active() { | |
return is_plugin_active( 'woocommerce/woocommerce.php' ); | |
} |
This file contains 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
<?php | |
public function start() { | |
if ( ! $this->woocommerce_is_active() ) { | |
return; | |
} | |
// Load dependencies. | |
} |
This file contains 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
<?php | |
public function stop() { | |
if ( ! $this->woocommerce_is_active() ) { | |
deactivate_plugins( plugin_basename( __FILE__ ) ); | |
unset( $_GET['activate'] ); // Input var okay. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment