$enabled
$enabled : bool
Global variable if Action Scheduler is active.
Class Init
$enabled : bool
Global variable if Action Scheduler is active.
$default_group : string
Action Scheduler group
$lib_path : string
Path to library
enqueue_async_action(string $hook, array $args = array(), string $group = '', bool $unique = false, int $priority = 10) : int
Enqueue an action to run one time, as soon as possible.
If Action Scheduler is disabled then do_action_ref_array is called to run action right away.
string | $hook | Required. Name of the action hook. |
array | $args | Arguments to pass to callbacks when the hook triggers. Default: array(). |
string | $group | The group to assign this job to. Default: ''. |
bool | $unique | Whether the action should be unique. Default: false. |
int | $priority | Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255. |
Еhe action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log
schedule_single_action(int $timestamp, string $hook, array $args = array(), string $group = '', bool $unique = false, int $priority = 10) : int
Schedule an action to run one time at some defined point in the future.
int | $timestamp | Required. The Unix timestamp representing the date you want the action to run. |
string | $hook | Required. Name of the action hook. |
array | $args | Arguments to pass to callbacks when the hook triggers. Default: array() |
string | $group | The group to assign this job to. Default: ''. |
bool | $unique | Whether the action should be unique. Default: false. |
int | $priority | Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255. |
The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
schedule_recurring_action(int $timestamp, int $interval_in_seconds, string $hook, array $args = array(), string $group = '', bool $unique = false, int $priority = 10) : int
Schedule an action to run repeatedly with a specified interval in seconds.
int | $timestamp | Required. The Unix timestamp representing the date you want the action to run. |
int | $interval_in_seconds | Required. How long to wait between runs. |
string | $hook | Required. Name of the action hook. |
array | $args | Arguments to pass to callbacks when the hook triggers. Default: array(). |
string | $group | The group to assign this job to. Default: ''. |
bool | $unique | Whether the action should be unique. Default: false. |
int | $priority | Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255. |
The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
schedule_cron_action(int $timestamp, string $schedule, string $hook, array $args = array(), string $group = '', bool $unique = false, int $priority = 10) : int
Schedule an action that recurs on a cron-like schedule.
If execution of a cron-like action is delayed, the next attempt will still be scheduled according to the provided cron expression.
int | $timestamp | Required. The Unix timestamp representing the date you want the action to run. |
string | $schedule | Required. A cron-like schedule string, see http://en.wikipedia.org/wiki/Cron. |
string | $hook | Required Name of the action hook. |
array | $args | Arguments to pass to callbacks when the hook triggers. Default: array(). |
string | $group | The group to assign this job to. Default: ''. |
bool | $unique | Whether the action should be unique. Default: false. |
int | $priority | Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255. |
The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
unschedule_action(string $hook, array $args = array(), string $group = '') : int|null
Cancel the next occurrence of a scheduled action.
string | $hook | Required. Name of the action hook. |
array | $args | Arguments passed to callbacks when the hook triggers. Default: array(). |
string | $group | The group the job is assigned to. Default: ''. |
The scheduled action ID if a scheduled action was found, or null if no matching action found.
unschedule_all_actions(string $hook, array $args = array(), string $group = '') : mixed
Cancel all occurrences of a scheduled action.
string | $hook | The hook that the job will trigger. |
array | $args | Args that would have been passed to the job. |
string | $group | The group the job is assigned to. |
next_scheduled_action(string $hook, array $args = array(), string $group = '') : int|bool
Returns the next timestamp for a scheduled action.
string | $hook | Required. Name of the action hook. Default: none. |
array | $args | Arguments passed to callbacks when the hook triggers. Default: array(). |
string | $group | The group the job is assigned to. Default: ''. |
The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action.
has_scheduled_action(string $hook, array $args = array(), string $group = '') : bool
Check if there is a scheduled action in the queue, but more efficiently than as_next_scheduled_action().
It’s recommended to use this function when you need to know whether a specific action is currently scheduled.
string | $hook | Required. Name of the action hook. Default: none. |
array | $args | Arguments passed to callbacks when the hook triggers. Default: array(). |
string | $group | The group the job is assigned to. Default: ''. |
True if a matching action is pending or in-progress, false otherwise.
get_scheduled_actions(array $args, string $return_format = 'OBJECT') : array
array | $args | Arguments to search and filter results by. Possible arguments, with their default values: 'hook' => '' - the name of the action that will be triggered 'args' => NULL - the args array that will be passed with the action 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). 'date_compare' => '<=' - operator for testing “date”. accepted values are ‘!=’, ‘>’, ‘>=’, ‘<’, ‘<=’, ‘=’ 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime(). 'modified_compare' => '<=' - operator for testing “modified”. accepted values are ‘!=’, ‘>’, ‘>=’, ‘<’, ‘<=’, ‘=’ 'group' => '' - the group the action belongs to 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID 'per_page' => 5 - Number of results to return 'offset' => 0 'orderby' => 'date' - accepted values are ‘hook’, ‘group’, ‘modified’, or ‘date’ 'order' => 'ASC' |
string | $return_format | The format in which to return the scheduled actions: 'OBJECT', 'ARRAY_A', or 'ids'. Default: 'OBJECT'. |
Array of action rows matching the criteria specified with $args.