<?php
namespace R2_Offload;

defined( 'ABSPATH' ) || exit;

final class Activator {

	public static function activate(): void {
		DB::install();
		if ( ! wp_next_scheduled( 'r2_offload_cron_tick' ) ) {
			wp_schedule_event( time() + 60, 'hourly', 'r2_offload_cron_tick' );
		}
		Logger::harden_log_dir(); // create logs/ + drop .htaccess/index.php deny guards.
		if ( ! Installer::vendor_ready() ) {
			Installer::install();
		}
	}

	public static function deactivate(): void {
		$ts = wp_next_scheduled( 'r2_offload_cron_tick' );
		if ( $ts ) {
			wp_unschedule_event( $ts, 'r2_offload_cron_tick' );
		}
	}
}
