1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75:
<?php
if (!class_exists('Inbound_Cron')) {
class Inbound_Cron {
function __construct() {
self::load_hooks();
}
public static function load_hooks() {
add_filter( 'cron_schedules', array( __CLASS__ , 'add_ping_interval' ) );
add_action( 'admin_init' , array( __CLASS__ , 'restore_heartbeats' ) );
add_filter( 'cron_schedules', array( __CLASS__ , 'add_ping_interval' ) );
}
public static function restore_heartbeats() {
if ( !wp_get_schedule('inbound_mailer_heartbeat') ) {
wp_schedule_event( time(), '2min', 'inbound_mailer_heartbeat' );
}
if ( !wp_get_schedule('inbound_automation_heartbeat') ) {
wp_schedule_event( time(), '2min', 'inbound_automation_heartbeat' );
}
}
public static function add_ping_interval( $schedules ) {
$schedules['2min'] = array(
'interval' => 60 * 2,
'display' => __( 'Every Two Minutes' , 'inbound-pro' )
);
return $schedules;
}
}
add_action('init' , function() {
new Inbound_Cron();
} , 1 );
}