<?php

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

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

$options = [
    'shop_to_llm_enabled',
    'shop_to_llm_api_key',
    'shop_to_llm_catalog_search',
    'shop_to_llm_analytics',
];

foreach ($options as $option) {
    delete_option($option);
}

for ($i = 0; $i < 30; $i++) {
    $date = gmdate('Y-m-d', strtotime("-{$i} days"));
    delete_transient('shop_to_llm_count_' . $date);
    delete_transient('shop_to_llm_searches_' . $date);
    delete_transient('shop_to_llm_crawlers_' . $date);
}
delete_transient('shop_to_llm_mcp_discovery');

global $wpdb;
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
    $wpdb->prepare(
        "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
        $wpdb->esc_like('_transient_shop_to_llm_') . '%'
    )
);
$wpdb->query(
    $wpdb->prepare(
        "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s",
        $wpdb->esc_like('_transient_timeout_shop_to_llm_') . '%'
    )
);
// phpcs:enable

flush_rewrite_rules();
