<?php
/**
 * Uninstall script for STWP plugin.
 *
 * This file is executed when the plugin is uninstalled via WordPress admin.
 * It cleans up plugin options while preserving user content and backups.
 *
 * @package STWP
 * @since 1.1.0
 */

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

/**
 * Clean up plugin options on uninstall.
 *
 * Note: This only removes settings. Converted files and backups are NOT deleted
 * to prevent accidental data loss. Users must manually delete backup files if desired.
 */
function stwp_uninstall_cleanup() {
	// Remove plugin settings.
	\delete_option( 'stwp_convert_to_webp' );
	\delete_option( 'stwp_max_width' );
	\delete_option( 'stwp_max_height' );
	\delete_option( 'stwp_compression_quality' );
	\delete_option( 'stwp_keep_original_backup' );
	\delete_option( 'stwp_force_webp' );

	// Remove bulk conversion state.
	\delete_option( 'stwp_bulk_queue' );
	\delete_option( 'stwp_bulk_done' );
	\delete_option( 'stwp_bulk_errors' );
	\delete_option( 'stwp_bulk_running' );

	// Clear any scheduled events.
	\wp_clear_scheduled_hook( 'stwp_process_batch' );
}

stwp_uninstall_cleanup();
