Action_Scheduler\WP_CLI\Action

Generate_Command::generateprotectedWC 1.0

Schedule multiple single actions.

Метод класса: Generate_Command{}

Хуков нет.

Возвращает

int[]. IDs of actions added.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->generate( $schedule_start, $interval, $count, $hook, $args, $group );
$schedule_start(int) (обязательный)
Starting timestamp of first action.
$interval(int) (обязательный)
How long to wait between runs.
$count(int) (обязательный)
Limit number of actions to schedule.
$hook(строка) (обязательный)
The hook to trigger.
$args(массив)
Arguments to pass when the hook triggers.
По умолчанию: array()
$group(строка)
The group to assign this job to.
По умолчанию: ''

Код Generate_Command::generate() WC 10.0.2

protected function generate( $schedule_start, $interval, $count, $hook, array $args = array(), $group = '' ) {
	$actions_added = array();

	$progress_bar = \WP_CLI\Utils\make_progress_bar(
		sprintf(
			/* translators: %d is number of actions to create */
			_n( 'Creating %d action', 'Creating %d actions', $count, 'woocommerce' ),
			number_format_i18n( $count )
		),
		$count
	);

	for ( $i = 0; $i < $count; $i++ ) {
		$actions_added[] = as_schedule_single_action( $schedule_start + ( $i * $interval ), $hook, $args, $group );
		$progress_bar->tick();
	}

	$progress_bar->finish();

	return $actions_added;
}