ActionScheduler_ActionFactory::get_stored_action()
Return stored actions for given params.
Method of the class: ActionScheduler_ActionFactory{}
Hooks from the method
Return
ActionScheduler_Action
. An instance of the stored action.
Usage
$ActionScheduler_ActionFactory = new ActionScheduler_ActionFactory(); $ActionScheduler_ActionFactory->get_stored_action( $status, $hook, $args, $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() - $schedule(ActionScheduler_Schedule)
- The action's 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 9.5.1
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 ); }