diff --git a/class-tgm-plugin-activation.php b/class-tgm-plugin-activation.php index 5cd628fb..eaedb324 100755 --- a/class-tgm-plugin-activation.php +++ b/class-tgm-plugin-activation.php @@ -1406,6 +1406,8 @@ public function register( $plugin ) { 'force_deactivation' => false, // Boolean. 'external_url' => '', // String. 'is_callable' => '', // String|Array. + 'class_exists' => '', // String. + 'is_defined' => '', // String. ); // Prepare the received data. @@ -1864,7 +1866,10 @@ public function is_plugin_installed( $slug ) { * @return bool True if active, false otherwise. */ public function is_plugin_active( $slug ) { - return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); + return ( ( ! empty( $this->plugins[ $slug ]['is_callable'] ) && is_callable( $this->plugins[ $slug ]['is_callable'] ) ) + || ( ! empty( $this->plugins[ $slug ]['class_exists'] ) && class_exists( $this->plugins[ $slug ]['class_exists'] ) ) + || ( ! empty( $this->plugins[ $slug ]['is_defined'] ) && defined( $this->plugins[ $slug ]['is_defined'] ) ) + || is_plugin_active( $this->plugins[ $slug ]['file_path'] ) ); } /** diff --git a/example.php b/example.php index df6c93fb..fcd431c2 100755 --- a/example.php +++ b/example.php @@ -70,6 +70,8 @@ function my_theme_register_required_plugins() { 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins. 'external_url' => '', // If set, overrides default API URL and points to an external URL. 'is_callable' => '', // If set, this callable will be be checked for availability to determine if a plugin is active. + 'class_exists' => '', // Same behavior as is_callable, this checks if a class exists to determine if a plugin is active. + 'is_defined' => '', // Same behavior as is_callable, this checks if a constant is defined to determine if a plugin is active. ), // This is an example of how to include a plugin from an arbitrary external source in your theme.