*/ class A1AI_Upgrade_Helper { /** * Check if the upgrade plugin is active AND has a valid license * * Checks multiple possible installation paths for the upgrade plugin * and validates that a valid license is active * * @since 1.0.0 * @return bool True if upgrade plugin is active with valid license, false otherwise */ public static function is_upgrade_active() { // Possible plugin paths $upgrade_paths = array( 'a1ai-chatbot-upgrade/a1ai-chatbot-upgrade.php', 'a1ai-chatbot-upgrade-new/a1ai-chatbot-upgrade.php', 'a1ai-chatbot-upgrade-new-x/a1ai-chatbot-upgrade.php' ); // Check if is_plugin_active function exists if (!function_exists('is_plugin_active')) { include_once(ABSPATH . 'wp-admin/includes/plugin.php'); } // Check each possible path $plugin_active = false; foreach ($upgrade_paths as $path) { if (function_exists('is_plugin_active') && is_plugin_active($path)) { $plugin_active = true; break; } } // If plugin not active, check if upgrade classes are loaded (handles edge cases) if (!$plugin_active) { // If upgrade plugin classes exist, the plugin is functionally active if (class_exists('A1AI_Upgrade') || class_exists('A1AI_Upgrade_EDD_License_Manager') || defined('A1AI_UPGRADE_VERSION')) { $plugin_active = true; } } // If plugin not active, return false if (!$plugin_active) { return false; } // Plugin is active — check license via EDD manager if available (most reliable) if (class_exists('A1AI_Upgrade_EDD_License_Manager')) { $license_manager = new A1AI_Upgrade_EDD_License_Manager(); return $license_manager->is_license_valid(); } // Fallback to option check return self::has_valid_license(); } /** * Check if the upgrade plugin is installed (files exist) * * @since 1.0.0 * @return bool True if upgrade plugin files exist, false otherwise */ public static function is_plugin_installed() { // Possible plugin paths $upgrade_paths = array( 'a1ai-chatbot-upgrade/a1ai-chatbot-upgrade.php', 'a1ai-chatbot-upgrade-new/a1ai-chatbot-upgrade.php', 'a1ai-chatbot-upgrade-new-x/a1ai-chatbot-upgrade.php' ); // Check if any of the plugin files exist foreach ($upgrade_paths as $path) { $full_path = WP_PLUGIN_DIR . '/' . $path; if (file_exists($full_path)) { return true; } } return false; } /** * Check if the upgrade plugin has a valid license * * @since 1.0.0 * @return bool True if valid license exists, false otherwise */ private static function has_valid_license() { // Check EDD license status $license_status = get_option('a1ai_upgrade_license_status', ''); return $license_status === 'valid'; } }