as_schedule_cron_action()
Schedule an action that recurs on a cron-like schedule.
Хуки из функции
Возвращает
int
. The action ID. Zero if there was an error scheduling the action.
Использование
as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group, $unique, $priority );
- $timestamp(int) (обязательный)
- The first instance of the action will be scheduled to run at a time calculated after this timestamp matching the cron expression. This can be used to delay the first instance of the action.
- $schedule(строка) (обязательный)
- A cron-link schedule string.
- $hook(строка) (обязательный)
- The hook to trigger.
- $args(массив)
- Arguments to pass when the hook triggers.
По умолчанию: array() - $group(строка)
- The group to assign this job to.
По умолчанию: '' - $unique(true|false)
- Whether the action should be unique. It will not be scheduled if another pending or running action has the same hook and group parameters.
По умолчанию: false - $priority(int)
- Lower values take precedence over higher values.
По умолчанию: 10, with acceptable values falling in the range 0-255
Заметки
- Смотрите: http://en.wikipedia.org/wiki/Cron
┬ ┬ ┬ ┬ ┬ ┬
| | | | | |
| | | | | + year [optional]
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
Код as_schedule_cron_action() as schedule cron action WC 9.4.2
function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) { if ( ! ActionScheduler::is_initialized( __FUNCTION__ ) ) { return 0; } /** * Provides an opportunity to short-circuit the default process for enqueuing cron * actions. * * Returning a value other than null from the filter will short-circuit the normal * process. The expectation in such a scenario is that callbacks will return an integer * representing the scheduled action ID (scheduled using some alternative process) or else * zero. * * @param int|null $pre_option The value to return instead of the option value. * @param int $timestamp When the action will run. * @param string $schedule Cron-like schedule string. * @param string $hook Action hook. * @param array $args Action arguments. * @param string $group Action group. * @param int $priority Action priority. */ $pre = apply_filters( 'pre_as_schedule_cron_action', null, $timestamp, $schedule, $hook, $args, $group, $priority ); if ( null !== $pre ) { return is_int( $pre ) ? $pre : 0; } return ActionScheduler::factory()->create( array( 'type' => 'cron', 'hook' => $hook, 'arguments' => $args, 'when' => $timestamp, 'pattern' => $schedule, 'group' => $group, 'unique' => $unique, 'priority' => $priority, ) ); }