[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> cron.php (summary)

WordPress Cron API

File Size: 991 lines (32 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 wp-cron.php

Defines 16 functions

  wp_schedule_single_event()
  wp_schedule_event()
  wp_reschedule_event()
  wp_unschedule_event()
  wp_clear_scheduled_hook()
  wp_unschedule_hook()
  wp_get_scheduled_event()
  wp_next_scheduled()
  spawn_cron()
  wp_cron()
  wp_get_schedules()
  wp_get_schedule()
  wp_get_ready_cron_jobs()
  _get_cron_array()
  _set_cron_array()
  _upgrade_cron_array()

Functions
Functions that are not part of a class:

wp_schedule_single_event( $timestamp, $hook, $args = array()   X-Ref
Schedules an event to run only once.

Schedules a hook which will be triggered by WordPress at the specified time.
The action will trigger when someone visits your WordPress site if the scheduled
time has passed.

Note that scheduling an event to occur within 10 minutes of an existing event
with the same action hook will be ignored unless you pass unique `$args` values
for each scheduled event.

Use wp_next_scheduled() to prevent duplicate events.

Use wp_schedule_event() to schedule a recurring event.

param: int    $timestamp  Unix timestamp (UTC) for when to next run the event.
param: string $hook       Action hook to execute when the event is run.
param: array  $args       Optional. Array containing each separate argument to pass to the hook's callback function.
return: bool True if event successfully scheduled. False for failure.

wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()   X-Ref
Schedules a recurring event.

Schedules a hook which will be triggered by WordPress at the specified interval.
The action will trigger when someone visits your WordPress site if the scheduled
time has passed.

Valid values for the recurrence are 'hourly', 'daily', and 'twicedaily'. These can
be extended using the {@see 'cron_schedules'} filter in wp_get_schedules().

Note that scheduling an event to occur within 10 minutes of an existing event
with the same action hook will be ignored unless you pass unique `$args` values
for each scheduled event.

Use wp_next_scheduled() to prevent duplicate events.

Use wp_schedule_single_event() to schedule a non-recurring event.

param: int    $timestamp  Unix timestamp (UTC) for when to next run the event.
param: string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values.
param: string $hook       Action hook to execute when the event is run.
param: array  $args       Optional. Array containing each separate argument to pass to the hook's callback function.
return: bool True if event successfully scheduled. False for failure.

wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()   X-Ref
Reschedules a recurring event.

Mainly for internal use, this takes the time stamp of a previously run
recurring event and reschedules it for its next run.

To change upcoming scheduled events, use wp_schedule_event() to
change the recurrence frequency.

param: int    $timestamp  Unix timestamp (UTC) for when the event was scheduled.
param: string $recurrence How often the event should subsequently recur. See wp_get_schedules() for accepted values.
param: string $hook       Action hook to execute when the event is run.
param: array  $args       Optional. Array containing each separate argument to pass to the hook's callback function.
return: bool True if event successfully rescheduled. False for failure.

wp_unschedule_event( $timestamp, $hook, $args = array()   X-Ref
Unschedule a previously scheduled event.

The $timestamp and $hook parameters are required so that the event can be
identified.

param: int    $timestamp Unix timestamp (UTC) of the event.
param: string $hook      Action hook of the event.
param: array  $args      Optional. Array containing each separate argument to pass to the hook's callback function.
return: bool True if event successfully unscheduled. False for failure.

wp_clear_scheduled_hook( $hook, $args = array()   X-Ref
Unschedules all events attached to the hook with the specified arguments.

Warning: This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE. For information about casting to booleans see the
{@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
the `===` operator for testing the return value of this function.

param: string $hook Action hook, the execution of which will be unscheduled.
param: array $args Optional. Arguments that were to be passed to the hook's callback function.
return: bool|int On success an integer indicating number of events unscheduled (0 indicates no

wp_unschedule_hook( $hook )   X-Ref
Unschedules all events attached to the hook.

Can be useful for plugins when deactivating to clean up the cron queue.

Warning: This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE. For information about casting to booleans see the
{@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
the `===` operator for testing the return value of this function.

param: string $hook Action hook, the execution of which will be unscheduled.
return: bool|int On success an integer indicating number of events unscheduled (0 indicates no

wp_get_scheduled_event( $hook, $args = array()   X-Ref
Retrieve a scheduled event.

Retrieve the full event object for a given event, if no timestamp is specified the next
scheduled event is returned.

param: string   $hook      Action hook of the event.
param: array    $args      Optional. Array containing each separate argument to pass to the hook's callback function.
param: int|null $timestamp Optional. Unix timestamp (UTC) of the event. If not specified, the next scheduled event is returned.
return: bool|object The event object. False if the event does not exist.

wp_next_scheduled( $hook, $args = array()   X-Ref
Retrieve the next timestamp for an event.

param: string $hook Action hook of the event.
param: array  $args Optional. Array containing each separate argument to pass to the hook's callback function.
return: false|int The Unix timestamp of the next time the event will occur. False if the event doesn't exist.

spawn_cron( $gmt_time = 0 )   X-Ref
Sends a request to run cron through HTTP request that doesn't halt page loading.

param: int $gmt_time Optional. Unix timestamp (UTC). Default 0 (current time is used).
return: bool True if spawned, false if no events spawned.

wp_cron()   X-Ref
Run scheduled callbacks or spawn cron for all scheduled events.

Warning: This function may return Boolean FALSE, but may also return a non-Boolean
value which evaluates to FALSE. For information about casting to booleans see the
{@link https://php.net/manual/en/language.types.boolean.php PHP documentation}. Use
the `===` operator for testing the return value of this function.

return: bool|int On success an integer indicating number of events spawned (0 indicates no

wp_get_schedules()   X-Ref
Retrieve supported event recurrence schedules.

The default supported recurrences are 'hourly', 'twicedaily', and 'daily'. A plugin may
add more by hooking into the {@see 'cron_schedules'} filter. The filter accepts an array
of arrays. The outer array has a key that is the name of the schedule or for
example 'weekly'. The value is an array with two keys, one is 'interval' and
the other is 'display'.

The 'interval' is a number in seconds of when the cron job should run. So for
'hourly', the time is 3600 or 60*60. For weekly, the value would be
60*60*24*7 or 604800. The value of 'interval' would then be 604800.

The 'display' is the description. For the 'weekly' key, the 'display' would
be `__( 'Once Weekly' )`.

For your plugin, you will be passed an array. you can easily add your
schedule by doing the following.

// Filter parameter variable name is 'array'.
$array['weekly'] = array(
'interval' => 604800,
'display'  => __( 'Once Weekly' )
);

return: array

wp_get_schedule( $hook, $args = array()   X-Ref
Retrieve the recurrence schedule for an event.

param: string $hook Action hook to identify the event.
param: array $args Optional. Arguments passed to the event's callback function.
return: string|false False, if no schedule. Schedule name on success.

wp_get_ready_cron_jobs()   X-Ref
Retrieve cron jobs ready to be run.

Returns the results of _get_cron_array() limited to events ready to be run,
ie, with a timestamp in the past.

return: array Cron jobs ready to be run.

_get_cron_array()   X-Ref
Retrieve cron info array option.

return: false|array CRON info array.

_set_cron_array( $cron )   X-Ref
Updates the CRON option with the new CRON array.

param: array $cron Cron info array from _get_cron_array().
return: bool True if cron array updated, false on failure.

_upgrade_cron_array( $cron )   X-Ref
Upgrade a Cron info array.

This function upgrades the Cron info array to version 2.

param: array $cron Cron info array from _get_cron_array().
return: array An upgraded Cron info array.



Generated: Sun Apr 21 08:20:01 2019 Cross-referenced by PHPXref 0.7