<?php
namespace FuseCommerce\Jobs;


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

use FuseCommerce\Hooks\FilterCronSchedules;


class Cron {

    const FUSE_COMM_HEARTBEAT = 'fuse_comm_heartbeat';

    static function addCronJobs(): void {

        if (!wp_next_scheduled(self::FUSE_COMM_HEARTBEAT)) {
            $minutesInTheFuture = 5;
            wp_schedule_event(strtotime("+{$minutesInTheFuture} minutes", time()), FilterCronSchedules::EVERY_MINUTE, self::FUSE_COMM_HEARTBEAT);
        }
    }

    static function removeCronJobs(): void {
        try {
            wp_clear_scheduled_hook(self::FUSE_COMM_HEARTBEAT);
        } catch (\Throwable $th) {
            //throw $th;
        }
        
    }
}