ActionScheduler_ActionFactory::async( string $hook, array $args = array(), string $group = '' )

Enqueue an action to run one time, as soon as possible (rather a specific scheduled time).


Description Description

This method creates a new action with the NULLSchedule. This schedule maps to a MySQL datetime string of 0000-00-00 00:00:00. This is done to create a psuedo "async action" type that is fully backward compatible. Existing queries to claim actions claim by date, meaning actions scheduled for 0000-00-00 00:00:00 will always be claimed prior to actions scheduled for a specific date. This makes sure that any async action is given priority in queue processing. This has the added advantage of making sure async actions can be claimed by both the existing WP Cron and WP CLI runners, as well as a new async request runner.


Parameters Parameters

$hook

(Required) The hook to trigger when this action runs

$args

(Optional) Args to pass when the hook is triggered

Default value: array()

$group

(Optional) A group to put the action in

Default value: ''


Top ↑

Return Return

(int) The ID of the stored action


Top ↑

Source Source

File: packages/action-scheduler/classes/ActionScheduler_ActionFactory.php


			


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.