ActionScheduler_ActionFactory
Located in classes/ActionScheduler_ActionFactory.php.
Creates and stores scheduled actions with different schedule types (async, single, recurring, cron) and can hydrate stored actions from persisted data. This class is an internal helper used by the scheduling API and queue infrastructure.
Public Methods
get_stored_action( $status, $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' )
Return a stored action instance based on status and schedule data.
- Parameters:
$status(string): Action status from the store (pending, canceled, etc.).$hook(string): Hook to trigger when the action runs.$args(array): Arguments passed to the hook callbacks.$schedule(ActionScheduler_Schedule|null): Schedule object for the action.$group(string): Group identifier.- Implicit 6th parameter:
$priority(int), accepted viafunc_get_arg( 5 )for backward compatibility.
- Returns:
ActionScheduler_Action
Notes:
$status(string): Action status from the store (pending, canceled, etc.).$hook(string): Hook to trigger when the action runs.$args(array): Arguments passed to the hook callbacks.$schedule(ActionScheduler_Schedule|null): Schedule object for the action.$group(string): Group identifier.- Implicit 6th parameter:
$priority(int), accepted viafunc_get_arg( 5 )for backward compatibility.
async( $hook, $args = array(), $group = '' )
Schedule an async action (NullSchedule), due “now”.
$status(string): Action status from the store (pending, canceled, etc.).$hook(string): Hook to trigger when the action runs.$args(array): Arguments passed to the hook callbacks.$schedule(ActionScheduler_Schedule|null): Schedule object for the action.$group(string): Group identifier.- Implicit 6th parameter:
$priority(int), accepted viafunc_get_arg( 5 )for backward compatibility.
async_unique( $hook, $args = array(), $group = '', $unique = true )
Async scheduling with optional uniqueness.
- Picks an action class based on status:
- pending →
ActionScheduler_Action - canceled →
ActionScheduler_CanceledAction(with schedule coerced toActionScheduler_CanceledSchedule) - otherwise →
ActionScheduler_FinishedAction
- pending →
- Applies filters:
action_scheduler_stored_action_classaction_scheduler_stored_action_instance
single( $hook, $args = array(), $when = null, $group = '' )
Schedule a single action at a specific timestamp.
- pending →
ActionScheduler_Action - canceled →
ActionScheduler_CanceledAction(with schedule coerced toActionScheduler_CanceledSchedule) - otherwise →
ActionScheduler_FinishedAction
single_unique( $hook, $args = array(), $when = null, $group = '', $unique = true )
Schedule a single action only if there is no pending/running action with the same hook and args.
action_scheduler_stored_action_classaction_scheduler_stored_action_instance
recurring( $hook, $args = array(), $first = null, $interval = null, $group = '' )
Schedule the first instance of an interval-based recurring action.
- pending →
ActionScheduler_Action - canceled →
ActionScheduler_CanceledAction(with schedule coerced toActionScheduler_CanceledSchedule) - otherwise →
ActionScheduler_FinishedAction
recurring_unique( $hook, $args = array(), $first = null, $interval = null, $group = '', $unique = true )
Recurring schedule with optional uniqueness. If $interval is empty, falls back to single_unique().
action_scheduler_stored_action_classaction_scheduler_stored_action_instance
cron( $hook, $args = array(), $base_timestamp = null, $schedule = null, $group = '' )
Schedule the first instance of a cron-based recurring action.
- Parameters:
$hook(string),$args(array),$group(string) - Returns:
intaction ID
cron_unique( $hook, $args = array(), $base_timestamp = null, $schedule = null, $group = '', $unique = true )
Cron scheduling with optional uniqueness. If $schedule is empty, falls back to single_unique().
- Parameters:
$hook(string),$args(array),$group(string),$unique(bool) - Returns:
intaction ID
repeat( $action )
Create the next instance for a recurring or cron action based on the current time.
- Parameters:
$hook(string),$args(array),$when(int|null),$group(string) - Returns:
intaction ID
create( array $options = array() )
General-purpose scheduling entry point used by the public API.
- Parameters:
$hook(string),$args(array),$when(int|null),$group(string),$unique(bool) - Returns:
intaction ID
Notes:
- Parameters:
$hook(string),$args(array),$first(int|null),$interval(int|null),$group(string) - Returns:
intaction ID
Filters
- Parameters:
$hook(string),$args(array),$first(int|null),$interval(int|null),$group(string),$unique(bool) - Returns:
intaction ID