ActionScheduler_ActionFactory::get_stored_action
Return stored actions for given params.
Method of the class: ActionScheduler_ActionFactory{}
Hooks from the method
Returns
ActionScheduler_Action. An instance of the stored action.
Usage
$ActionScheduler_ActionFactory = new ActionScheduler_ActionFactory(); $ActionScheduler_ActionFactory->get_stored_action( $status, $hook, $args, ?ActionScheduler_Schedule $schedule, $group );
- $status(string) (required)
- The action's status in the data store.
- $hook(string) (required)
- The hook to trigger when this action runs.
- $args(array)
- Args to pass to callbacks when the hook is triggered.
Default: array() - ?ActionScheduler_Schedule $schedule
- .
Default: null - $group(string)
- A group to put the action in. phpcs:ignore Squiz.Commenting.FunctionComment.ExtraParamComment.
Default: ''
ActionScheduler_ActionFactory::get_stored_action() ActionScheduler ActionFactory::get stored action code WC 10.4.3
public function get_stored_action( $status, $hook, array $args = array(), ?ActionScheduler_Schedule $schedule = null, $group = '' ) {
// The 6th parameter ($priority) is not formally declared in the method signature to maintain compatibility with
// third-party subclasses created before this param was added.
$priority = func_num_args() >= 6 ? (int) func_get_arg( 5 ) : 10;
switch ( $status ) {
case ActionScheduler_Store::STATUS_PENDING:
$action_class = 'ActionScheduler_Action';
break;
case ActionScheduler_Store::STATUS_CANCELED:
$action_class = 'ActionScheduler_CanceledAction';
if ( ! is_null( $schedule ) && ! is_a( $schedule, 'ActionScheduler_CanceledSchedule' ) && ! is_a( $schedule, 'ActionScheduler_NullSchedule' ) ) {
$schedule = new ActionScheduler_CanceledSchedule( $schedule->get_date() );
}
break;
default:
$action_class = 'ActionScheduler_FinishedAction';
break;
}
$action_class = apply_filters( 'action_scheduler_stored_action_class', $action_class, $status, $hook, $args, $schedule, $group );
$action = new $action_class( $hook, $args, $schedule, $group );
$action->set_priority( $priority );
/**
* Allow 3rd party code to change the instantiated action for a given hook, args, schedule and group.
*
* @param ActionScheduler_Action $action The instantiated action.
* @param string $hook The instantiated action's hook.
* @param array $args The instantiated action's args.
* @param ActionScheduler_Schedule $schedule The instantiated action's schedule.
* @param string $group The instantiated action's group.
* @param int $priority The action priority.
*/
return apply_filters( 'action_scheduler_stored_action_instance', $action, $hook, $args, $schedule, $group, $priority );
}