<?php
/**
 * Fired when the plugin is uninstalled.
 *
 * @package Replyan_AI
 */

// If uninstall not called from WordPress, then exit.
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

global $wpdb;

// phpcs:disable WordPress.DB.DirectDatabaseQuery
// phpcs:disable PluginCheck.Security.DirectDB.UnescapedDBParameter

// Drop custom tables.
$replyan_ai_sessions_table = $wpdb->prefix . 'replyan_ai_sessions';
$replyan_ai_messages_table = $wpdb->prefix . 'replyan_ai_messages';

// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( "DROP TABLE IF EXISTS {$replyan_ai_sessions_table}" );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared
$wpdb->query( "DROP TABLE IF EXISTS {$replyan_ai_messages_table}" );

// Delete options.
delete_option( 'replyan_ai_settings' );
delete_option( 'replyan_ai_db_version' );
