<?php
/**
 * Plugin uninstall cleanup.
 *
 * Removes plugin options and transient/user-meta counters used for protection
 * caching/trial bookkeeping. Design/template content is intentionally preserved.
 */

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

// Core plugin options.
delete_option('ds_settings');
delete_option('ds_protection_instance_id');

global $wpdb;
if ($wpdb instanceof wpdb) {
    // Remove protection/trial transient counters (guest actor keys).
    $wpdb->query(
        "DELETE FROM {$wpdb->options}
         WHERE option_name LIKE '_transient_ds_trial_used_%'
            OR option_name LIKE '_transient_timeout_ds_trial_used_%'"
    );

    // Remove trial counters for logged-in users.
    $wpdb->query(
        $wpdb->prepare(
            "DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s",
            '_ds_trial_used'
        )
    );
}

