Action_Scheduler\WP_CLI\Action

Cancel_Command::cancel_single()protectedWC 1.0

Cancel single action.

Method of the class: Cancel_Command{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->cancel_single( $hook, $callback_args, $group );
$hook(string) (required)
The hook that the job will trigger.
$callback_args(array) (required)
Args that would have been passed to the job.
$group(string) (required)
The group the job is assigned to.

Cancel_Command::cancel_single() code WC 9.8.2

protected function cancel_single( $hook, $callback_args, $group ) {
	if ( empty( $hook ) ) {
		\WP_CLI::error( __( 'Please specify hook of action to cancel.', 'woocommerce' ) );
	}

	try {
		$result = as_unschedule_action( $hook, $callback_args, $group );
	} catch ( \Exception $e ) {
		$this->print_error( $e, false );
	}

	if ( null === $result ) {
		$e = new \Exception( __( 'Unable to cancel scheduled action: check the logs.', 'woocommerce' ) );
		$this->print_error( $e, false );
	}

	$this->print_success( false );
}