ActionScheduler_ActionFactory::recurring_unique
Create the first instance of an action recurring on a given interval 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->recurring_unique( $hook, $args, $first, $interval, $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() - $first(int)
- Unix timestamp for the first run.
Default:null - $interval(int)
- Seconds between runs.
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::recurring_unique() ActionScheduler ActionFactory::recurring unique code WC 10.5.0
public function recurring_unique( $hook, $args = array(), $first = null, $interval = null, $group = '', $unique = true ) {
if ( empty( $interval ) ) {
return $this->single_unique( $hook, $args, $first, $group, $unique );
}
$date = as_get_datetime_object( $first );
$schedule = new ActionScheduler_IntervalSchedule( $date, $interval );
$action = new ActionScheduler_Action( $hook, $args, $schedule, $group );
return $unique ? $this->store_unique_action( $action ) : $this->store( $action );
}