ActionScheduler_ActionFactory::single_unique()publicWC 1.0

Create single action only if there is no pending or running action with same name and params.

Method of the class: ActionScheduler_ActionFactory{}

No Hooks.

Return

Int. The ID of the stored action.

Usage

$ActionScheduler_ActionFactory = new ActionScheduler_ActionFactory();
$ActionScheduler_ActionFactory->single_unique( $hook, $args, $when, $group, $unique );
$hook(string) (required)
The hook to trigger when this action runs.
$args(array)
Args to pass when the hook is triggered.
Default: array()
$when(int)
Unix timestamp when the action will run.
Default: null
$group(string)
A group to put the action in.
Default: ''
$unique(true|false)
Whether action scheduled should be unique.
Default: true

ActionScheduler_ActionFactory::single_unique() code WC 8.6.1

public function single_unique( $hook, $args = array(), $when = null, $group = '', $unique = true ) {
	$date     = as_get_datetime_object( $when );
	$schedule = new ActionScheduler_SimpleSchedule( $date );
	$action   = new ActionScheduler_Action( $hook, $args, $schedule, $group );
	return $unique ? $this->store_unique_action( $action ) : $this->store( $action );
}