[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

WordPress Cron API

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

Defines 17 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_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 UTC 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 arguments to pass to the
param: bool   $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
return: bool|WP_Error True if event successfully scheduled. False or WP_Error on 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', 'twicedaily', 'daily', and 'weekly'.
These can be extended using the {@see 'cron_schedules'} filter in wp_get_schedules().

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.
param: string $hook       Action hook to execute when the event is run.
param: array  $args       Optional. Array containing arguments to pass to the
param: bool   $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
return: bool|WP_Error True if event successfully scheduled. False or WP_Error on failure.

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

Mainly for internal use, this takes the UTC timestamp 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.
param: string $hook       Action hook to execute when the event is run.
param: array  $args       Optional. Array containing arguments to pass to the
param: bool   $wp_error   Optional. Whether to return a WP_Error on failure. Default false.
return: bool|WP_Error True if event successfully rescheduled. False or WP_Error on failure.

wp_unschedule_event( $timestamp, $hook, $args = array()   X-Ref
Unschedules 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.
param: bool   $wp_error  Optional. Whether to return a WP_Error on failure. Default false.
return: bool|WP_Error True if event successfully unscheduled. False or WP_Error on 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://www.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. Array containing each separate argument to pass to the hook's callback function.
param: bool   $wp_error Optional. Whether to return a WP_Error on failure. Default false.
return: int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no

wp_unschedule_hook( $hook, $wp_error = false )   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://www.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: bool   $wp_error Optional. Whether to return a WP_Error on failure. Default false.
return: int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no

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

Retrieves 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
return: object|false {

wp_next_scheduled( $hook, $args = array()   X-Ref
Retrieves 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: int|false 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
Registers _wp_cron() to run on the {@see 'wp_loaded'} action.

If the {@see 'wp_loaded'} action has already fired, this function calls
_wp_cron() directly.

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://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
the `===` operator for testing the return value of this function.

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

_wp_cron()   X-Ref
Runs scheduled callbacks or spawns 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://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
the `===` operator for testing the return value of this function.

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

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

The default supported recurrences are 'hourly', 'twicedaily', 'daily', and 'weekly'.
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, for example 'monthly'. 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 `HOUR_IN_SECONDS` (`60 * 60` or `3600`). For 'monthly',
the value would be `MONTH_IN_SECONDS` (`30 * 24 * 60 * 60` or `2592000`).

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

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

// Filter parameter variable name is 'array'.
$array['monthly'] = array(
'interval' => MONTH_IN_SECONDS,
'display'  => __( 'Once Monthly' )
);

return: array {

wp_get_schedule( $hook, $args = array()   X-Ref
Retrieves the name of 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 Schedule name on success, false if no schedule.

wp_get_ready_cron_jobs()   X-Ref
Retrieves 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[] Array of cron job arrays ready to be run.

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

return: array[] Array of cron events.

_set_cron_array( $cron, $wp_error = false )   X-Ref
Updates the cron option with the new cron array.

param: array[] $cron     Array of cron info arrays from _get_cron_array().
param: bool    $wp_error Optional. Whether to return a WP_Error on failure. Default false.
return: bool|WP_Error True if cron array updated. False or WP_Error on failure.

_upgrade_cron_array( $cron )   X-Ref
Upgrades 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 : Tue Dec 24 08:20:01 2024 Cross-referenced by PHPXref