/home/coolpkct/public_html/websites/alylela.com/wp-content/plugins/wp-db-scout/uninstall.php
<?php
/**
 * Uninstall WP DB Scout
 *
 * Removes all plugin data when deleted from WordPress
 *
 * @package    WP_DB_Scout
 * @since      2.0.0
 */

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

global $wpdb;

// Remove all plugin options
delete_option('wds_version');
delete_option('wds_search_limit');
delete_option('wds_cache_duration');
delete_option('wds_auth_timeout');
delete_option('wds_protection_enabled');
delete_option('wds_protection_notification_email');
delete_option('wds_protection_db_version');

// Remove all user meta related to plugin
$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE 'wds_%'");

// Drop cache table
$cache_table = $wpdb->prefix . 'wds_search_cache';
$wpdb->query("DROP TABLE IF EXISTS {$cache_table}");

// Get all WDS triggers before dropping tables
$triggers = $wpdb->get_results(
    "SELECT TRIGGER_NAME 
     FROM information_schema.TRIGGERS 
     WHERE TRIGGER_SCHEMA = DATABASE() 
     AND TRIGGER_NAME LIKE 'wds_%'",
    ARRAY_A
);

// Drop all WDS triggers
if (!empty($triggers)) {
    foreach ($triggers as $trigger) {
        $wpdb->query("DROP TRIGGER IF EXISTS `{$trigger['TRIGGER_NAME']}`");
    }
}

// Drop Link Protection tables
$protection_tables = array(
    $wpdb->prefix . 'wds_protection_log',
    $wpdb->prefix . 'wds_trigger_config',
    $wpdb->prefix . 'wds_protected_links'
);

foreach ($protection_tables as $table) {
    $wpdb->query("DROP TABLE IF EXISTS {$table}");
}

// Remove capabilities
$role = get_role('administrator');
if ($role) {
    $role->remove_cap('wds_view_server_info');
    $role->remove_cap('wds_search_database');
    $role->remove_cap('wds_manage_link_protection');
}

// Clear scheduled cron events
wp_clear_scheduled_hook('wds_check_protected_links');
wp_clear_scheduled_hook('wds_daily_protection_report');

// Clear any transients
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_wds_%'");
$wpdb->query("DELETE FROM {$wpdb->options} WHERE option_name LIKE '_transient_timeout_wds_%'");