<?php

declare(strict_types=1);

namespace Australcode\Rewards;

defined( 'ABSPATH' ) || exit;

/**
 * Runs on plugin deactivation. Intentionally conservative: never drops tables
 * or deletes data here (data removal lives in Uninstaller, on after_uninstall,
 * behind the explicit delete_data_on_uninstall opt-in). Unschedules the plugin's
 * WP-Cron events. License revalidation is owned by the Freemius SDK (no plugin
 * cron to clean up).
 */
final class Deactivator {

	public static function deactivate(): void {
		foreach ( array( 'acrwd_expire_points', 'acrwd_birthday_tick', 'acrwd_points_expiring_tick', 'acrwd_redemption_refund_tick' ) as $hook ) {
			$timestamp = wp_next_scheduled( $hook );
			if ( false !== $timestamp ) {
				wp_unschedule_event( $timestamp, $hook );
			}
		}
		flush_rewrite_rules();
	}
}
