Technical Details for PublishPress Future

In another documentation article, we explained that the scheduling is handled by a cron job and the _ppfuture_actions_args table.

This post will explain more about that process and how it works.


Adding an expiry date to posts #

On every post save, the PublishPress Future plugin will check if a Future action is enabled in the post.

  • If the feature is enabled, the plugin stores the data set in the Future Action metabox in the _ppfuture_actions_args table and schedules a cron task. 
  • If the feature is not enabled, it will ignore any cron task for it.

About the PublishPress Future cron jobs #

The cron task itself only has a name of the hook: postExpiratorExpire, and the post ID.

By default, the cron task is handled by WordPress, so it can be enabled (undefined or DISABLE_WP_CRON = true), or disabled (DISABLE_WP_CRON = false).

  • If WordPress is handling the cron, WordPress will trigger the cron job based on visits to the site. That is not very precise for sites with low traffic.
  • If WordPress is not handling the cron, additional settings should be done to make sure there is a cronjob in the server running the cron tasks periodically.

The cron task is scheduled with the selected date and time for the action. 


What happens when the cron job runs #

When the cron task runs, it will call the action publishpressfuture_run_workflow which will receive the post ID found in the cron task argument.

Next, the cron task will read the _ppfuture_actions_args table for the specific post, looking for the other settings, such as the action type.

Finally, the cron task handles the future action according to the selected for the post.