includes/lib/action-scheduler/deprecatedfunctions.php

Deprecated API functions for scheduling actions

Functions with the wc prefix were deprecated to avoid confusion with Action Scheduler being included in WooCommerce core, and it providing a different set of APIs for working with the action queue.

Functions

wc_schedule_single_action()

wc_schedule_single_action(int  $timestamp, string  $hook, array  $args = array(), string  $group = '') : string

Schedule an action to run one time.

Parameters

int $timestamp

When the job will run.

string $hook

The hook to trigger.

array $args

Arguments to pass when the hook triggers.

string $group

The group to assign this job to.

Returns

string —

The job ID

wc_schedule_recurring_action()

wc_schedule_recurring_action(int  $timestamp, int  $interval_in_seconds, string  $hook, array  $args = array(), string  $group = '') : string

Schedule a recurring action.

Parameters

int $timestamp

When the first instance of the job will run.

int $interval_in_seconds

How long to wait between runs.

string $hook

The hook to trigger.

array $args

Arguments to pass when the hook triggers.

string $group

The group to assign this job to.

Returns

string —

The job ID

wc_schedule_cron_action()

wc_schedule_cron_action(int  $timestamp, string  $schedule, string  $hook, array  $args = array(), string  $group = '') : string

Schedule an action that recurs on a cron-like schedule.

Parameters

int $timestamp

The schedule will start on or after this time.

string $schedule

A cron-link schedule string.

string $hook

The hook to trigger.

array $args

Arguments to pass when the hook triggers.

string $group

The group to assign this job to.

Returns

string —

The job ID

wc_unschedule_action()

wc_unschedule_action(string  $hook, array  $args = array(), string  $group = '') : mixed

Cancel the next occurrence of a job.

Parameters

string $hook

The hook that the job will trigger.

array $args

Args that would have been passed to the job.

string $group

Action's group.

Returns

mixed

wc_next_scheduled_action()

wc_next_scheduled_action(string  $hook, array  $args = null, string  $group = '') : int|bool

Get next scheduled action.

Parameters

string $hook

Action's hook.

array $args

Action's args.

string $group

Action's group.

Returns

int|bool —

The timestamp for the next occurrence, or false if nothing was found

wc_get_scheduled_actions()

wc_get_scheduled_actions(array  $args = array(), string  $return_format = OBJECT) : array

Find scheduled actions

Parameters

array $args

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(). Used in UTC timezone. '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(). Used in UTC timezone. '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

OBJECT, ARRAY_A, or ids.

Returns

array