<?php

defined('WP_UNINSTALL_PLUGIN') || exit;

// Operational and security records are retained by default. A site owner must
// explicitly opt in before uninstalling if they want the plugin to erase them.
if (!get_option('capture_relay_erase_on_uninstall', false)) {
    return;
}

global $wpdb;
foreach (['requests', 'devices', 'blocks', 'rate_limits', 'nonces', 'uploads', 'activity'] as $capture_relay_suffix) {
    $wpdb->query($wpdb->prepare(
        'DROP TABLE IF EXISTS %i',
        $wpdb->prefix . 'capture_relay_' . $capture_relay_suffix
    ));
}

delete_option('capture_relay_settings');
delete_option('capture_relay_db_version');
delete_option('capture_relay_erase_on_uninstall');
delete_option('capture_relay_needs_setup');
