Tribe__Process__Handler::dispatch()
Overrides the base dispatch method to allow for constants and/or environment vars to run async requests in sync mode.
Return
(mixed)
Source
File: src/Tribe/Process/Handler.php
public function dispatch() {
if (
( defined( 'TRIBE_NO_ASYNC' ) && true === TRIBE_NO_ASYNC )
|| true == getenv( 'TRIBE_NO_ASYNC' )
) {
return $this->sync_handle( $this->data );
}
if ( $this->feature_detection->supports_async_process() ) {
return parent::dispatch();
}
/*
* If async AJAX-based processing is not available then we "dispatch"
* by scheduling a single cron event immediately (as soon as possible)
* for this handler cron identifier.
*/
if ( ! wp_next_scheduled( $this->cron_hook_identifier, array( $this->data ) ) ) {
// Schedule the event to happen as soon as possible.
$scheduled = wp_schedule_single_event( time() - 1, $this->cron_hook_identifier, array( $this->data ) );
if ( false === $scheduled ) {
/** @var Tribe__Log__Logger $logger */
$logger = tribe( 'logger' );
$class = get_class( $this );
$src = call_user_func( array( $class, 'action' ) );
$logger->log( 'Could not schedule event for cron-based handling', Tribe__Log::ERROR, $src );
}
}
return true;
}
Changelog
| Version | Description |
|---|---|
| 4.9.5 | Pulled dispatch method logic from the WP_Async_Request class. |
| 4.7.12 | Introduced. |