Object_Sync_Sf_Queue
Object_Sync_Sf_Queue class.
Table of Contents
- $file : string
- The main plugin file
- $option_prefix : string
- The plugin's prefix when saving options to the database
- $schedulable_classes : array<string|int, mixed>
- Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
- $slug : string
- The plugin's slug so we can include it when necessary
- $version : string
- Current version of the plugin
- $wpdb : object
- Global object of `$wpdb`, the WordPress database
- __construct() : mixed
- Constructor for queue class
- action_scheduler_batch_size() : int
- Set the batch size.
- action_scheduler_concurrent_batches() : int
- Set the number of concurrent batches that can run.
- add() : string
- Enqueue an action to run one time, as soon as possible
- cancel() : mixed
- Dequeue all actions with a matching hook (and optionally matching args and group) so they are not run.
- get_frequencies() : array<string|int, mixed>
- Get all the schedules with their frequencies, sorted
- get_frequency() : int
- Get a single schedule item's frequency
- get_next() : timestamp|null
- Get the date and time for the next scheduled occurence of an action with a given hook (an optionally that matches certain args and group), if any.
- schedule_cron() : string
- Schedule an action that recurs on a cron-like schedule.
- schedule_recurring() : string
- Schedule a recurring action
- schedule_single() : string
- Schedule an action to run once at some time in the future
- search() : array<string|int, mixed>
- Find scheduled actions
- add_actions() : mixed
- Add actions
Properties
$file
The main plugin file
public
string
$file
$option_prefix
The plugin's prefix when saving options to the database
public
string
$option_prefix
$schedulable_classes
Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
public
array<string|int, mixed>
$schedulable_classes
$slug
The plugin's slug so we can include it when necessary
public
string
$slug
$version
Current version of the plugin
public
string
$version
$wpdb
Global object of `$wpdb`, the WordPress database
public
object
$wpdb
Methods
__construct()
Constructor for queue class
public
__construct() : mixed
Return values
mixed —action_scheduler_batch_size()
Set the batch size.
public
action_scheduler_batch_size(int $batch_size) : int
Parameters
- $batch_size : int
-
how big the batch is.
Return values
int —$batch_size
action_scheduler_concurrent_batches()
Set the number of concurrent batches that can run.
public
action_scheduler_concurrent_batches(int $concurrent_batches) : int
Parameters
- $concurrent_batches : int
-
how many batches can run at once.
Return values
int —$concurrent_batches
add()
Enqueue an action to run one time, as soon as possible
public
add(string $hook[, array<string|int, mixed> $args = array() ][, string $group = '' ]) : string
Parameters
- $hook : string
-
The hook to trigger.
- $args : array<string|int, mixed> = array()
-
Arguments to pass when the hook triggers.
- $group : string = ''
-
The group to assign this job to.
Return values
string —The action ID.
cancel()
Dequeue all actions with a matching hook (and optionally matching args and group) so they are not run.
public
cancel(string $hook[, array<string|int, mixed> $args = array() ][, string $group = '' ]) : mixed
Any recurring actions with a matching hook will also be cancelled, not just the next scheduled action.
Technically, one action in a recurring or Cron action is scheduled at any one point in time. The next in the sequence is scheduled after the previous one is run, so only the next scheduled action needs to be cancelled/dequeued to stop the sequence.
Parameters
- $hook : string
-
The hook that the job will trigger.
- $args : array<string|int, mixed> = array()
-
Args that would have been passed to the job.
- $group : string = ''
-
Group name.
Return values
mixed —get_frequencies()
Get all the schedules with their frequencies, sorted
public
get_frequencies([string $unit = 'seconds' ][, string $sort = 'asc' ]) : array<string|int, mixed>
Parameters
- $unit : string = 'seconds'
-
The unit of time.
- $sort : string = 'asc'
-
Which direction to sort.
Return values
array<string|int, mixed> —$this->schedulable_classes
get_frequency()
Get a single schedule item's frequency
public
get_frequency(string $name, string $unit) : int
Parameters
- $name : string
-
The name of the schedule.
- $unit : string
-
The unit of time.
Return values
int —How often it runs in that unit of time
get_next()
Get the date and time for the next scheduled occurence of an action with a given hook (an optionally that matches certain args and group), if any.
public
get_next(string $hook[, array<string|int, mixed> $args = null ][, string $group = '' ]) : timestamp|null
Parameters
- $hook : string
-
Hook name.
- $args : array<string|int, mixed> = null
-
Arguments.
- $group : string = ''
-
Group name.
Return values
timestamp|null —The date and time for the next occurrence, or null if there is no pending, scheduled action for the given hook.
schedule_cron()
Schedule an action that recurs on a cron-like schedule.
public
schedule_cron(int $timestamp, string $cron_schedule, string $hook[, array<string|int, mixed> $args = array() ][, string $group = '' ]) : string
Parameters
- $timestamp : int
-
The schedule will start on or after this time.
- $cron_schedule : string
-
A cron-link schedule string.
- $hook : string
-
The hook to trigger.
- $args : array<string|int, mixed> = array()
-
Arguments to pass when the hook triggers.
- $group : string = ''
-
The group to assign this job to.
Tags
Return values
string —The action ID
schedule_recurring()
Schedule a recurring action
public
schedule_recurring(int $timestamp, int $interval_in_seconds, string $hook[, array<string|int, mixed> $args = array() ][, string $group = '' ]) : string
Parameters
- $timestamp : int
-
When the first instance of the job will run.
- $interval_in_seconds : int
-
How long to wait between runs.
- $hook : string
-
The hook to trigger.
- $args : array<string|int, mixed> = array()
-
Arguments to pass when the hook triggers.
- $group : string = ''
-
The group to assign this job to.
Return values
string —The action ID.
schedule_single()
Schedule an action to run once at some time in the future
public
schedule_single(int $timestamp, string $hook[, array<string|int, mixed> $args = array() ][, string $group = '' ]) : string
Parameters
- $timestamp : int
-
When the job will run.
- $hook : string
-
The hook to trigger.
- $args : array<string|int, mixed> = array()
-
Arguments to pass when the hook triggers.
- $group : string = ''
-
The group to assign this job to.
Return values
string —The action ID.
search()
Find scheduled actions
public
search([array<string|int, mixed> $args = array() ][, string $return_format = OBJECT ]) : array<string|int, mixed>
Parameters
- $args : array<string|int, mixed> = array()
-
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'.
- $return_format : string = OBJECT
-
OBJECT, ARRAY_A, or ids.
Return values
array<string|int, mixed> —add_actions()
Add actions
private
add_actions() : mixed