60, // 60 seconds = 1 minute 'display' => __('Every Minute', 'rl-mailwarmer'), ]; $schedules['every_five_minutes'] = [ 'interval' => 300, 'display' => __('Every 5 Minutes', 'rl-mailwarmer'), ]; } return $schedules; } /** * Schedule the cron task if not already scheduled. */ public static function schedule_cron_jobs() { // Message handler if (!wp_next_scheduled('rl_mailwarmer_process_messages')) { wp_schedule_event(time(), 'every_minute', 'rl_mailwarmer_process_messages'); } // Conversation handler if (!wp_next_scheduled('rl_mailwarmer_process_upcoming_conversations')) { wp_schedule_event(time(), 'every_minute', 'rl_mailwarmer_process_upcoming_conversations'); } } /** * Clear the scheduled task. */ public static function clear_cron_jobs() { // Message handler $timestamp = wp_next_scheduled('rl_mailwarmer_process_messages'); if ($timestamp) { wp_unschedule_event($timestamp, 'rl_mailwarmer_process_messages'); } // Conversation handler $timestamp = wp_next_scheduled('rl_mailwarmer_process_upcoming_conversations'); if ($timestamp) { wp_unschedule_event($timestamp, 'rl_mailwarmer_process_upcoming_conversations'); } } /** * Process pending messages by delegating to the Message Handler. */ public static function process_pending_messages() { // log_to_file("schedule_cron_jobs ====================== Running Cron to process messages ========================"); // RL_MailWarmer_Message_Handler::process_pending_messages(); } /** * Process pending conversations by delegating to the Message Handler. */ public static function process_upcoming_conversations() { // log_to_file("schedule_cron_jobs ====================== Running Cron to process conversations ========================"); // RL_MailWarmer_Message_Handler::process_upcoming_conversations(); } }