<?php
/**
 * Uninstall handler for CookieJar.
 *
 * Remove stored options and transients created by the plugin.
 * Only delete data that users reasonably expect to be removed on uninstall.
 */

if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;

// Single-site options (adjust keys to your plugin).
delete_option( 'cookiejar_settings' );
delete_option( 'cookiejar_version' );

// Network options (uncomment if you used add_site_option()).
// delete_site_option( 'cookiejar_network_settings' );

if ( is_multisite() ) {
    // Iterate all sites and delete per-site options.
    $sites = function_exists( 'get_sites' ) ? get_sites( [ 'fields' => 'ids' ] ) : [];
    if ( $sites ) {
        foreach ( $sites as $site_id ) {
            switch_to_blog( (int) $site_id );
            delete_option( 'cookiejar_settings' );
            delete_option( 'cookiejar_version' );
            restore_current_blog();
        }
    }
}
