<?php
/**
 * Uninstall Thia Aide Comment Moderator
 *
 * @package ThiaAideCommentModerator
 */

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

global $wpdb;

$tables = [
    'thiaide_moderator_api_keys',
    'thiaide_moderator_blocked_ips',
    'thiaide_moderator_blocked_users',
    'thiaide_moderator_warnings',
    'thiaide_moderator_api_stats',
];

foreach ( $tables as $table ) {
    $table_name = $wpdb->prefix . $table;
    // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.PreparedSQL.InterpolatedNotPrepared
    $wpdb->query( "DROP TABLE IF EXISTS `{$table_name}`" );
}

// Clear any transients
delete_transient( 'thia_rate_limit_moderate_' );
delete_transient( 'thia_rate_limit_save_' );