WooCommerce Code Reference

SchedulerTraits

SchedulerTraits class.

Table of Contents

$group  : string|null
Action scheduler group.
$queue  : WC_Queue_Interface
Queue instance.
clear_queued_actions()  : mixed
Clears all queued actions.
do_action_or_reschedule()  : mixed
Check for blocking jobs and reschedule if any exist.
flatten_args()  : string
Flatten multidimensional arrays to store for scheduling.
get_action()  : string|null
Get an action tag name from the action name.
get_actions()  : mixed
Get all available scheduling actions.
get_batch_size()  : int
Returns the batch size for an action.
get_batch_sizes()  : mixed
Batch action size.
get_default_scheduler_actions()  : mixed
Gets the default scheduler actions for batching and scheduling actions.
get_dependencies()  : array<string|int, mixed>
Returns an array of actions and dependencies as key => value pairs.
get_dependency()  : string|null
Get dependencies associated with an action.
get_next_action_time()  : DateTime|null
Get the DateTime for the next scheduled time an action should run.
get_next_blocking_job()  : false|ActionScheduler_Action
Get the next blocking job for an action.
get_scheduler_actions()  : array<string|int, mixed>
Gets the actions for this specific scheduler.
has_existing_jobs()  : bool
Check if existing jobs exist for an action and arguments.
init()  : mixed
Add all actions as hooks.
queue()  : WC_Queue_Interface
Get queue instance.
queue_batches()  : void
Queue a large number of batch jobs, respecting the batch size limit.
schedule_action()  : mixed
Schedule an action to run and check for dependencies.
set_queue()  : mixed
Set queue instance.

Properties

Methods

flatten_args()

Flatten multidimensional arrays to store for scheduling.

public static flatten_args(array<string|int, mixed> $args) : string
Parameters
$args : array<string|int, mixed>

Argument array.

Return values
string

get_action()

Get an action tag name from the action name.

public static get_action(string $action_name) : string|null
Parameters
$action_name : string

The action name.

Return values
string|null

get_actions()

Get all available scheduling actions.

public static get_actions() : mixed

Used to determine action hook names and clear events.

Return values
mixed

get_batch_size()

Returns the batch size for an action.

public static get_batch_size(string $action) : int
Parameters
$action : string

Single batch action name.

Return values
intBatch size.

get_default_scheduler_actions()

Gets the default scheduler actions for batching and scheduling actions.

public static get_default_scheduler_actions() : mixed
Return values
mixed

get_dependencies()

Returns an array of actions and dependencies as key => value pairs.

public static get_dependencies() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_dependency()

Get dependencies associated with an action.

public static get_dependency(string $action_name) : string|null
Parameters
$action_name : string

The action slug.

Return values
string|null

get_next_action_time()

Get the DateTime for the next scheduled time an action should run.

public static get_next_action_time(ActionScheduler_Action $action) : DateTime|null

This function allows backwards compatibility with Action Scheduler < v3.0.

Parameters
$action : ActionScheduler_Action

Action.

Return values
DateTime|null

get_next_blocking_job()

Get the next blocking job for an action.

public static get_next_blocking_job(string $action_name) : false|ActionScheduler_Action
Parameters
$action_name : string

Action name.

Return values
false|ActionScheduler_Action

get_scheduler_actions()

Gets the actions for this specific scheduler.

public static get_scheduler_actions() : array<string|int, mixed>
Return values
array<string|int, mixed>

has_existing_jobs()

Check if existing jobs exist for an action and arguments.

public static has_existing_jobs(string $action_name, array<string|int, mixed> $args) : bool
Parameters
$action_name : string

Action name.

$args : array<string|int, mixed>

Array of arguments to pass to action.

Return values
bool

queue_batches()

Queue a large number of batch jobs, respecting the batch size limit.

public static queue_batches(int $range_start, int $range_end, string $single_batch_action[, array<string|int, mixed> $action_args = array() ]) : void

Reduces a range of batches down to "single batch" jobs.

Parameters
$range_start : int

Starting batch number.

$range_end : int

Ending batch number.

$single_batch_action : string

Action to schedule for a single batch.

$action_args : array<string|int, mixed> = array()

Action arguments.

Return values
void

schedule_action()

Schedule an action to run and check for dependencies.

public static schedule_action(string $action_name[, array<string|int, mixed> $args = array() ]) : mixed
Parameters
$action_name : string

Action name.

$args : array<string|int, mixed> = array()

Array of arguments to pass to action.

Return values
mixed

set_queue()

Set queue instance.

public static set_queue(WC_Queue_Interface $queue) : mixed
Parameters
$queue : WC_Queue_Interface

Queue instance.

Return values
mixed