<?php

if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}

$uploads = wp_upload_dir();

define('WTB_FIREWALL_UPLOAD_PATH', trailingslashit($uploads['basedir']) . 'wtb-firewall/');
    
define('WTB_FIREWALL_PATH', plugin_dir_path(__FILE__));
require_once WTB_FIREWALL_PATH . 'Admin/Includes.php';

\WtbFirewall\Config\FirewallConfig::loadOptions();

//Fjern firewall.
$firewall = new \WtbFirewall\Firewall\Firewall();
$firewall->removeFirewall();

//include(plugin_dir_path(__FILE__) . 'Firewall/Firewall.php');
//Sjekk om vi skal slette alle data eller ikke.
if (\WtbFirewall\Config\FirewallConfig::$deleteOnUninstall === true) {
    //Slett alt fra databasen.
    global $wpdb;

    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wtb_firewall_events');
    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wtb_firewall_ips');
    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'wtb_firewall_log');

    delete_option('wtb_firewall_settings');
    delete_option('wtb_firewall_version');
}