'0', // Default: hide part of IP address (privacy-safe) 'actlogpro_enable_json_feed' => '0' // Default: JSON feed disabled // Note: RSS feed is NOT a premium feature, so it's not reset ); foreach ($premium_settings as $setting => $default_value) { update_option($setting, $default_value); } // Clear any feed tokens when disabling feeds (only JSON since RSS is not premium) delete_option('actlogpro_json_feed_token'); delete_option('actlogpro_feed_token_updated'); // Set persistent flag to show admin notice (user must manually dismiss) update_option('actlogpro_premium_settings_reset_notice', true); // Log the reset action if (class_exists('ACTLOGPRO_Logger')) { ACTLOGPRO_Logger::log_activity_minimal( 'system', 'settings', 0, 'Premium Settings Reset', 'premium_settings_reset', 'Premium features have been disabled and settings reset to defaults' ); } } /** * Check if we need to reset premium settings when switching from premium to free * * @since 1.0.0 */ private static function maybe_reset_premium_settings_on_downgrade() { $was_premium = get_option('actlogpro_was_premium_enabled', false); $is_premium = self::is_premium_enabled_without_reset_check(); // If we were premium but now we're not, reset settings if ($was_premium && !$is_premium) { self::reset_premium_settings_to_defaults(); update_option('actlogpro_was_premium_enabled', false); } } /** * Check if we need to track premium state when upgrading to premium * * @since 1.0.0 */ private static function maybe_reset_premium_settings_on_upgrade() { $was_premium = get_option('actlogpro_was_premium_enabled', false); $is_premium = self::is_premium_enabled_without_reset_check(); // If we weren't premium but now we are, track the state if (!$was_premium && $is_premium) { update_option('actlogpro_was_premium_enabled', true); } } /** * Ensure IP setting is privacy-safe when premium is not enabled * * @since 1.0.0 */ private static function ensure_privacy_safe_ip_setting() { $current_setting = get_option('actlogpro_store_full_ip', '0'); // If setting is set to store full IP but premium is not enabled, reset to privacy-safe default if ($current_setting === '1') { update_option('actlogpro_store_full_ip', '0'); // Log this action for transparency if (class_exists('ACTLOGPRO_Logger')) { ACTLOGPRO_Logger::log_activity_minimal( 'system', 'settings', 0, 'IP Privacy Setting', 'auto_privacy_reset', 'IP address setting automatically reset to privacy-safe default due to premium deactivation' ); } } } /** * Check premium status without triggering reset checks (to avoid infinite recursion) * * @since 1.0.0 * @return bool True if premium features should be enabled */ private static function is_premium_enabled_without_reset_check() { // Development Constants 004 // Check if premium extension is registered and active if (class_exists('ACTLOGPRO_Extension_Interface')) { $premium_extension_active = ACTLOGPRO_Extension_Interface::is_extension_registered('activity-log-pro-premium'); if ($premium_extension_active) { // Extension is registered, now check if license is valid $license_valid = get_option('actlogpro_premium_license_valid', '0') === '1'; return $license_valid; } } // Legacy check for premium plugin activation if (function_exists('is_plugin_active') && is_plugin_active('activity-log-pro-premium/activity-log-pro-premium.php')) { return true; } return false; } }