LLMS_Notifications::schedule_single_processor( LLMS_Abstract_Notification_Processor $processor, string $id )

Save pending batches and schedule the async dispatching of a processor.


Parameters Parameters

$processor

(LLMS_Abstract_Notification_Processor) (Required) Notification processor object.

$id

(string) (Required) Processor ID.


Top ↑

Return Return

(int|WP_Error) Timestamp of the scheduled event or an error object.


Top ↑

Source Source

File: includes/notifications/class.llms.notifications.php

	 * @return int|WP_Error Timestamp of the scheduled event or an error object.
	 */
	protected function schedule_single_processor( $processor, $id ) {

		$hook = 'llms_dispatch_notification_processor_async';
		$args = array( $id );

		// Save items in the queue.
		$processor->save();

		// Check if there's already a scheduled event.
		$timestamp = as_next_scheduled_action( $hook, $args );

		// If there's no event scheduled already, schedule one.
		if ( ! $timestamp ) {

			$timestamp = llms_current_time( 'timestamp', 1 );

			// Error encountered scheduling the event.
			if ( ! as_schedule_single_action( $timestamp, $hook, $args ) ) {
				$timestamp = new WP_Error(
					'schedule-error',
					// Translators: %s = Processor ID.
					sprintf( __( 'There was an error dispatching the "%s" processor.', 'lifterlms' ), $id )
				);
			}
		}

		return $timestamp;


Top ↑

Changelog Changelog

Changelog
Version Description
3.38.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.