ActionScheduler_Abstract_QueueRunner::process_action() public WC 1.0
Process an individual action.
{} It's a method of the class: ActionScheduler_Abstract_QueueRunner{}
Hooks from the method
Return
Null. Nothing.
Usage
$ActionScheduler_Abstract_QueueRunner = new ActionScheduler_Abstract_QueueRunner(); $ActionScheduler_Abstract_QueueRunner->process_action( $action_id, $context );
- $action_id(int) (required)
- The action ID to process.
- $context(string)
- Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' Generally, this should be capitalised and not localised as it's a proper noun.
Code of ActionScheduler_Abstract_QueueRunner::process_action() ActionScheduler Abstract QueueRunner::process action WC 5.0.0
public function process_action( $action_id, $context = '' ) {
try {
$valid_action = false;
do_action( 'action_scheduler_before_execute', $action_id, $context );
if ( ActionScheduler_Store::STATUS_PENDING !== $this->store->get_status( $action_id ) ) {
do_action( 'action_scheduler_execution_ignored', $action_id, $context );
return;
}
$valid_action = true;
do_action( 'action_scheduler_begin_execute', $action_id, $context );
$action = $this->store->fetch_action( $action_id );
$this->store->log_execution( $action_id );
$action->execute();
do_action( 'action_scheduler_after_execute', $action_id, $action, $context );
$this->store->mark_complete( $action_id );
} catch ( Exception $e ) {
if ( $valid_action ) {
$this->store->mark_failure( $action_id );
do_action( 'action_scheduler_failed_execution', $action_id, $e, $context );
} else {
do_action( 'action_scheduler_failed_validation', $action_id, $e, $context );
}
}
if ( isset( $action ) && is_a( $action, 'ActionScheduler_Action' ) && $action->get_schedule()->is_recurring() ) {
$this->schedule_next_instance( $action, $action_id );
}
}