is_marked_active = $is_marked_active; // Set default properties $this->set_properties(); // Check if this is a premium integration and premium is not enabled $premium_integrations = array('woocommerce', 'yoast'); if (in_array($this->integration_id, $premium_integrations) && !ACTLOGPRO_Premium_Helper::is_premium_enabled()) { // Don't register hooks for premium integrations when premium is disabled return; } // Register hooks $this->register_hooks(); } /** * Set the properties of this integration. * * @since 1.0.0 */ abstract protected function set_properties(); /** * Register the hooks related to this integration. * * @since 1.0.0 */ abstract protected function register_hooks(); /** * Get the integration ID. * * @since 1.0.0 * @return string The ID of this integration. */ public function get_id() { return $this->integration_id; } /** * Get the integration name. * * @since 1.0.0 * @return string The name of this integration. */ public function get_name() { return $this->integration_name; } /** * Get the integration description. * * @since 1.0.0 * @return string The description of this integration. */ public function get_description() { return $this->integration_description; } /** * Get the plugin dependency. * * @since 1.0.0 * @return string The plugin file path that this integration depends on. */ public function get_plugin_dependency() { return $this->plugin_dependency; } /** * Check if the integration is active. * * @since 1.0.0 * @return boolean True if the integration is active, false otherwise. */ public function is_active() { // Check if this is a premium integration and premium is not enabled $premium_integrations = array('woocommerce', 'yoast'); if (in_array($this->integration_id, $premium_integrations) && !ACTLOGPRO_Premium_Helper::is_premium_enabled()) { return false; } // Check if the integration file exists $integration_id = $this->get_id(); // For premium integrations, check in premium directory first if (in_array($this->integration_id, $premium_integrations) && defined('ACTLOGPRO_PREMIUM_PLUGIN_DIR')) { $premium_file_path = ACTLOGPRO_PREMIUM_PLUGIN_DIR . 'integrations/class-alp-' . $integration_id . '-integration.php'; $file_exists = file_exists($premium_file_path); } else { // For free integrations, check in free plugin directory $integration_file_path = ACTLOGPRO_PLUGIN_DIR . 'integrations/' . $integration_id . '/class-alp-' . $integration_id . '-integration.php'; $default_file_path = ACTLOGPRO_PLUGIN_DIR . 'integrations/class-alp-' . $integration_id . '-integration.php'; $file_exists = file_exists($integration_file_path) || file_exists($default_file_path); } if (!$file_exists) { return false; } // Check if the plugin dependency is active if (!empty($this->plugin_dependency)) { // For WooCommerce, we need a special check if ($this->plugin_dependency === 'woocommerce/woocommerce.php') { // Check if WooCommerce is active using multiple methods $is_plugin_active = is_plugin_active($this->plugin_dependency); $wc_function_exists = function_exists('WC'); $wc_class_exists = class_exists('WooCommerce'); if (!($is_plugin_active || ($wc_function_exists && $wc_class_exists))) { return false; } } else if ($this->plugin_dependency === 'wordpress-seo/wp-seo.php') { // Check if Yoast SEO is active using multiple methods $is_plugin_active = is_plugin_active($this->plugin_dependency); $yoast_function_exists = function_exists('WPSEO'); $yoast_class_exists = class_exists('WPSEO_Options'); if (!($is_plugin_active || ($yoast_function_exists || $yoast_class_exists))) { return false; } } else if (!is_plugin_active($this->plugin_dependency)) { return false; } } // Check if this integration is marked as active in the settings if (!$this->is_marked_active) { return false; } // If all checks pass, consider it active return true; } }