Created
January 23, 2017 13:01
-
-
Save yanknudtskov/d0350a51ac7a7adbcff378aad22a72e6 to your computer and use it in GitHub Desktop.
Require one or more plugins 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
| <?php | |
| Class PLUGIN_CLASS { | |
| private $required_plugins = array( 'woocommerce' ); | |
| function have_required_plugins() { | |
| if (empty($this->required_plugins)) | |
| return true; | |
| $active_plugins = (array) get_option('active_plugins', array()); | |
| if (is_multisite()) { | |
| $active_plugins = array_merge( $active_plugins, get_site_option('active_sitewide_plugins', array()) ); | |
| } | |
| foreach ($this->required_plugins as $key => $required) { | |
| $required = (!is_numeric($key)) ? "{$key}/{$required}.php" : "{$required}/{$required}.php"; | |
| if (!in_array($required, $active_plugins) && !array_key_exists($required, $active_plugins)) | |
| return false; | |
| } | |
| return true; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment