prefix . 'a1ai_chatbots', $wpdb->prefix . 'a1ai_conversations', $wpdb->prefix . 'a1ai_messages', $wpdb->prefix . 'a1ai_adjustments', $wpdb->prefix . 'a1ai_quality_events', $wpdb->prefix . 'a1ai_business_info', $wpdb->prefix . 'a1ai_system_prompts', $wpdb->prefix . 'a1ai_custom_instructions', ); // Cache any relevant data that might be needed later $tables_exist_cache = wp_cache_get('a1ai_tables_exist', 'a1ai'); if (false !== $tables_exist_cache) { wp_cache_delete('a1ai_tables_exist', 'a1ai'); } // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery // Direct database queries are necessary for uninstall operations // phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching // No caching needed for uninstall operations // phpcs:disable WordPress.DB.DirectDatabaseQuery.SchemaChange // Schema changes are necessary for uninstall operations foreach ($tables as $table) { // Use backtick escaping for table names (safe as derived from trusted prefix + hardcoded strings) $safe_table = '`' . str_replace('`', '``', $table) . '`'; // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safely escaped with backticks $wpdb->query("DROP TABLE IF EXISTS $safe_table"); } // phpcs:enable WordPress.DB.DirectDatabaseQuery.SchemaChange // phpcs:enable WordPress.DB.DirectDatabaseQuery.NoCaching // phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery // Remove any transients delete_transient('a1ai_activation_redirect'); delete_transient('a1ai_usage_stats_cache'); // Clear scheduled hooks wp_clear_scheduled_hook('a1ai_daily_maintenance'); } // If we decide to add any user capabilities, we would remove them here