michaeluno / Task-Scheduler

Provides a task management system for WordPress
Other
14 stars 7 forks source link

How does Task-scheduler schedule tasks without depending on page-load? #13

Closed iamlearningdeveloper closed 6 years ago

iamlearningdeveloper commented 6 years ago

Hi,

Can you please let me know that how does this plugin schedule taks without depending on page load. I looked into code but could not understand how can it schedule a task if there is no visitor to the site?

PS: I know this is not a support question but found the forum pretty inactive so posted here. Apologies for the same.

michaeluno commented 6 years ago

Hi,

It actually relies on page load done in the background by Server Heartbeat. It uses HTTP API and keeps accessing the site itself. Created tasks are stored as a post with a custom post type. In every background page load, the plugin checks whether there are tasks close to the current time. And those found tasks are picked and wait for the execution time and run in another separate background page load.