From 8a4875af76b1347fbe3c2b6ef5b04ea7d3c79563 Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sun, 4 Sep 2022 16:11:54 -0700 Subject: [PATCH 1/3] add a check to see if plugin is already active with Sensei Pro --- sensei-content-drip.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/sensei-content-drip.php b/sensei-content-drip.php index 1a6f493..9cbffdf 100644 --- a/sensei-content-drip.php +++ b/sensei-content-drip.php @@ -21,19 +21,28 @@ exit; } -define( 'SENSEI_CONTENT_DRIP_VERSION', '2.1.1' ); -define( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE', __FILE__ ); -define( 'SENSEI_CONTENT_DRIP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); +function sensei_content_drip_requirements_met() { + if ( defined( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE' ) ) { + return false; + } + return true; +} -require_once dirname( __FILE__ ) . '/includes/class-scd-ext-dependency-checker.php'; +if ( sensei_content_drip_requirements_met() ) { + define( 'SENSEI_CONTENT_DRIP_VERSION', '2.1.1' ); + define( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE', __FILE__ ); + define( 'SENSEI_CONTENT_DRIP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); -if ( ! Scd_Ext_Dependency_Checker::are_system_dependencies_met() ) { - return; -} + require_once dirname( __FILE__ ) . '/includes/class-scd-ext-dependency-checker.php'; -require_once dirname( __FILE__ ) . '/includes/class-sensei-content-drip.php'; + if ( ! Scd_Ext_Dependency_Checker::are_system_dependencies_met() ) { + return; + } -// Load the plugin after all the other plugins have loaded. -add_action( 'plugins_loaded', array( 'Sensei_Content_Drip', 'init' ), 5 ) ; + require_once dirname( __FILE__ ) . '/includes/class-sensei-content-drip.php'; -Sensei_Content_Drip::instance(); + // Load the plugin after all the other plugins have loaded. + add_action( 'plugins_loaded', array( 'Sensei_Content_Drip', 'init' ), 5 ) ; + + Sensei_Content_Drip::instance(); +} From 441b838a04ec7def3a18bc530b97213b379493c2 Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Sun, 4 Sep 2022 16:26:32 -0700 Subject: [PATCH 2/3] use existing dependency check class --- includes/class-scd-ext-dependency-checker.php | 12 +++++++ sensei-content-drip.php | 32 ++++++++----------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/includes/class-scd-ext-dependency-checker.php b/includes/class-scd-ext-dependency-checker.php index 54ba12d..cdcc3ff 100644 --- a/includes/class-scd-ext-dependency-checker.php +++ b/includes/class-scd-ext-dependency-checker.php @@ -38,6 +38,18 @@ public static function are_system_dependencies_met() { return $are_met; } + /** + * Checks if plugin already active through Sensei Pro. + * + * @return bool + */ + public static function is_sensei_pro_active() { + if ( defined( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE' ) ) { + return true; + } + return false; + } + /** * Checks if all plugin dependencies are met. * diff --git a/sensei-content-drip.php b/sensei-content-drip.php index 9cbffdf..43a011e 100644 --- a/sensei-content-drip.php +++ b/sensei-content-drip.php @@ -20,29 +20,23 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } +require_once dirname( __FILE__ ) . '/includes/class-scd-ext-dependency-checker.php'; -function sensei_content_drip_requirements_met() { - if ( defined( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE' ) ) { - return false; - } - return true; +if ( Scd_Ext_Dependency_Checker::is_sensei_pro_active() ) { + return; } -if ( sensei_content_drip_requirements_met() ) { - define( 'SENSEI_CONTENT_DRIP_VERSION', '2.1.1' ); - define( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE', __FILE__ ); - define( 'SENSEI_CONTENT_DRIP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); +define( 'SENSEI_CONTENT_DRIP_VERSION', '2.1.1' ); +define( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE', __FILE__ ); +define( 'SENSEI_CONTENT_DRIP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); - require_once dirname( __FILE__ ) . '/includes/class-scd-ext-dependency-checker.php'; - - if ( ! Scd_Ext_Dependency_Checker::are_system_dependencies_met() ) { - return; - } +if ( ! Scd_Ext_Dependency_Checker::are_system_dependencies_met() ) { + return; +} - require_once dirname( __FILE__ ) . '/includes/class-sensei-content-drip.php'; +require_once dirname( __FILE__ ) . '/includes/class-sensei-content-drip.php'; - // Load the plugin after all the other plugins have loaded. - add_action( 'plugins_loaded', array( 'Sensei_Content_Drip', 'init' ), 5 ) ; +// Load the plugin after all the other plugins have loaded. +add_action( 'plugins_loaded', array( 'Sensei_Content_Drip', 'init' ), 5 ) ; - Sensei_Content_Drip::instance(); -} +Sensei_Content_Drip::instance(); From a3dc38b75b8e9abd5971f544d430339663d6259a Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Tue, 6 Sep 2022 11:32:26 -0700 Subject: [PATCH 3/3] change constant for sensei pro check --- includes/class-scd-ext-dependency-checker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-scd-ext-dependency-checker.php b/includes/class-scd-ext-dependency-checker.php index cdcc3ff..dc96a96 100644 --- a/includes/class-scd-ext-dependency-checker.php +++ b/includes/class-scd-ext-dependency-checker.php @@ -44,7 +44,7 @@ public static function are_system_dependencies_met() { * @return bool */ public static function is_sensei_pro_active() { - if ( defined( 'SENSEI_CONTENT_DRIP_PLUGIN_FILE' ) ) { + if ( defined( 'SENSEI_PRO_VERSION' ) ) { return true; } return false;