(int) $heartbeat_interval, // Seconds. 'display' => 'Plugin AdScale / Heartbeat', ); return $schedules; } ); // Cron hook. if ( ! wp_next_scheduled( 'adscale_heartbeat_hook' ) ) { wp_schedule_event( time(), 'adscale_heartbeat', 'adscale_heartbeat_hook' ); } // Action for hook. add_action( 'adscale_heartbeat_hook', array( API_Manager::class, 'process_heartbeat' ) ); } /** * Deactivate the heartbeat schedule and clear the hook. * * @return void */ public static function deactivate() { if ( function_exists( '\wp_unschedule_hook' ) ) { \wp_unschedule_hook( 'adscale_heartbeat_hook' ); } else { \wp_clear_scheduled_hook( 'adscale_heartbeat_hook' ); } } }