wp_schedule_single_event

Definition:
function wp_schedule_single_event( $timestamp, $hook, $args = array() {}

Schedules a hook to run only once.
Schedules a hook which will be executed once by the WordPress actions core at a time which you specify. The action will fire off when someone visits your WordPress site, if the schedule time has passed.

Parameters

  • int $timestamp: Timestamp for when to run the event.
  • string $hook: Action hook to execute when cron is run.
  • array $args: Optional. Arguments to pass to the hook’s callback function.

Defined filters

  • schedule_event
    apply_filters('schedule_event', $event)

Source code

function wp_schedule_single_event( $timestamp, $hook, $args = array()) {

	// don't schedule a duplicate if there's already an identical event due in the next 10 minutes

	$next = wp_next_scheduled($hook, $args);

	if ( $next && $next <= $timestamp + 600 )

		return;



	$crons = _get_cron_array();

	$event = (object) array( 'hook' => $hook, 'timestamp' => $timestamp, 'schedule' => false, 'args' => $args );

	$event = apply_filters('schedule_event', $event);



	// A plugin disallowed this event

	if ( ! $event )

		return false;



	$key = md5(serialize($event->args));



	$crons[$event->timestamp][$event->hook][$key] = array( 'schedule' => $event->schedule, 'args' => $event->args );

	uksort( $crons, "strnatcasecmp" );

	_set_cron_array( $crons );

}

4089

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: