ActionScheduler_ActionFactory::single_unique
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.
Returns
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() ActionScheduler ActionFactory::single unique code WC 10.3.6
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 );
}