ActionScheduler_QueueRunner::run
Process actions in the queue. Attached to self::WP_CRON_HOOK i.e. action_scheduler_run_queue
The $context param of this method defaults to 'WP Cron', because prior to Action Scheduler 3.0.0 that was the only context in which this method was run, and the self::WP_CRON_HOOK hook had no context passed along with it. New code calling this method directly, or by triggering the self::WP_CRON_HOOK, should set a context as the first parameter. For an example of this, refer to the code seen in
Метод класса: ActionScheduler_QueueRunner{}
Хуки из метода
Возвращает
int. The number of actions processed.
Использование
$ActionScheduler_QueueRunner = new ActionScheduler_QueueRunner(); $ActionScheduler_QueueRunner->run( $context );
- $context(строка)
- Optional identifier for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' Generally, this should be capitalised and not localised as it's a proper noun.
По умолчанию: 'WP Cron'
Заметки
Код ActionScheduler_QueueRunner::run() ActionScheduler QueueRunner::run WC 10.3.4
public function run( $context = 'WP Cron' ) {
ActionScheduler_Compatibility::raise_memory_limit();
ActionScheduler_Compatibility::raise_time_limit( $this->get_time_limit() );
do_action( 'action_scheduler_before_process_queue' );
$this->run_cleanup();
$this->processed_actions_count = 0;
if ( false === $this->has_maximum_concurrent_batches() ) {
do {
$batch_size = apply_filters( 'action_scheduler_queue_runner_batch_size', 25 );
$processed_actions_in_batch = $this->do_batch( $batch_size, $context );
$this->processed_actions_count += $processed_actions_in_batch;
} while ( $processed_actions_in_batch > 0 && ! $this->batch_limits_exceeded( $this->processed_actions_count ) ); // keep going until we run out of actions, time, or memory.
}
do_action( 'action_scheduler_after_process_queue' );
return $this->processed_actions_count;
}