ActionScheduler_QueueRunner::init
Initialize.
Method of the class: ActionScheduler_QueueRunner{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$ActionScheduler_QueueRunner = new ActionScheduler_QueueRunner(); $ActionScheduler_QueueRunner->init();
ActionScheduler_QueueRunner::init() ActionScheduler QueueRunner::init code WC 10.5.0
public function init() {
add_filter( 'cron_schedules', array( self::instance(), 'add_wp_cron_schedule' ) ); // phpcs:ignore WordPress.WP.CronInterval.CronSchedulesInterval
// Check for and remove any WP Cron hook scheduled by Action Scheduler < 3.0.0, which didn't include the $context param.
$next_timestamp = wp_next_scheduled( self::WP_CRON_HOOK );
if ( $next_timestamp ) {
wp_unschedule_event( $next_timestamp, self::WP_CRON_HOOK );
}
$cron_context = array( 'WP Cron' );
if ( ! wp_next_scheduled( self::WP_CRON_HOOK, $cron_context ) ) {
$schedule = apply_filters( 'action_scheduler_run_schedule', self::WP_CRON_SCHEDULE );
wp_schedule_event( time(), $schedule, self::WP_CRON_HOOK, $cron_context );
}
add_action( self::WP_CRON_HOOK, array( self::instance(), 'run' ) );
$this->hook_dispatch_async_request();
}