Make WordPress Core


Ignore:
Timestamp:
09/04/2008 07:12:40 PM (16 years ago)
Author:
ryan
Message:

phpdoc for cron.php. Props jacobsantos and hansengel. fixes #5637

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/cron.php

    r8572 r8806  
    11<?php
    2 
     2/**
     3 * WordPress CRON API
     4 *
     5 * @package WordPress
     6 */
     7
     8/**
     9 * Schedules a hook to run only once.
     10 *
     11 * Schedules a hook which will be executed once by the Wordpress actions core at
     12 * a time which you specify. The action will fire off when someone visits your
     13 * WordPress site, if the schedule time has passed.
     14 *
     15 * @since 2.1.0
     16 * @link http://codex.wordpress.org/Function_Reference/wp_schedule_single_event
     17 *
     18 * @param int $timestamp Timestamp for when to run the event.
     19 * @param callback $hook Function or method to call, when cron is run.
     20 * @param array $args Optional. Arguments to pass to the hook function.
     21 */
    322function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
    423    $crons = _get_cron_array();
     
    928}
    1029
     30/**
     31 * Schedule a periodic event.
     32 *
     33 * Schedules a hook which will be executed by the WordPress actions core on a
     34 * specific interval, specified by you. The action will trigger when someone
     35 * visits your WordPress site, if the scheduled time has passed.
     36 *
     37 * @since 2.1.0
     38 *
     39 * @param int $timestamp Timestamp for when to run the event.
     40 * @param string $recurrence How often the event should recur.
     41 * @param callback $hook Function or method to call, when cron is run.
     42 * @param array $args Optional. Arguments to pass to the hook function.
     43 * @return bool|null False on failure, null when complete with scheduling event.
     44 */
    1145function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) {
    1246    $crons = _get_cron_array();
     
    2054}
    2155
     56/**
     57 * Reschedule a recurring event.
     58 *
     59 * @since 2.1.0
     60 *
     61 * @param int $timestamp Timestamp for when to run the event.
     62 * @param string $recurrence How often the event should recur.
     63 * @param callback $hook Function or method to call, when cron is run.
     64 * @param array $args Optional. Arguments to pass to the hook function.
     65 * @return bool|null False on failure. Null when event is rescheduled.
     66 */
    2267function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) {
    2368    $crons = _get_cron_array();
     
    4287}
    4388
     89/**
     90 * Unschedule a previously scheduled cron job.
     91 *
     92 * The $timestamp and $hook parameters are required, so that the event can be
     93 * identified.
     94 *
     95 * @since 2.1.0
     96 *
     97 * @param int $timestamp Timestamp for when to run the event.
     98 * @param callback $hook Function or method to call, when cron is run.
     99 * @param array $args Optional. Arguments to pass to the hook function.
     100 */
    44101function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
    45102    $crons = _get_cron_array();
     
    53110}
    54111
     112/**
     113 * Unschedule all cron jobs attached to a specific hook.
     114 *
     115 * @since 2.1.0
     116 *
     117 * @param callback $hook Function or method to call, when cron is run.
     118 * @param mixed $args,... Optional. Event arguments.
     119 */
    55120function wp_clear_scheduled_hook( $hook ) {
    56121    $args = array_slice( func_get_args(), 1 );
     
    60125}
    61126
     127/**
     128 * Retrieve the next timestamp for a cron event.
     129 *
     130 * @since 2.1.0
     131 *
     132 * @param callback $hook Function or method to call, when cron is run.
     133 * @param array $args Optional. Arguments to pass to the hook function.
     134 * @return bool|int The UNIX timestamp of the next time the scheduled event will occur.
     135 */
    62136function wp_next_scheduled( $hook, $args = array() ) {
    63137    $crons = _get_cron_array();
     
    77151 * @since 2.1.0
    78152 *
    79  * @return null CRON could not be spawned, because it is not needed to run.
     153 * @return null Cron could not be spawned, because it is not needed to run.
    80154 */
    81155function spawn_cron() {
     
    94168}
    95169
     170/**
     171 * Run scheduled callbacks or spawn cron for all scheduled events.
     172 *
     173 * @since 2.1.0
     174 *
     175 * @return null When doesn't need to run Cron.
     176 */
    96177function wp_cron() {
    97178    // Prevent infinite loops caused by lack of wp-cron.php
     
    120201}
    121202
     203/**
     204 * Retrieve supported and filtered Cron recurrences.
     205 *
     206 * The supported recurrences are 'hourly' and 'daily'. A plugin may add more by
     207 * hooking into the 'cron_schedules' filter. The filter accepts an array of
     208 * arrays. The outer array has a key that is the name of the schedule or for
     209 * example 'weekly'. The value is an array with two keys, one is 'interval' and
     210 * the other is 'display'.
     211 *
     212 * The 'interval' is a number in seconds of when the cron job should run. So for
     213 * 'hourly', the time is 3600 or 60*60. For weekly, the value would be
     214 * 60*60*24*7 or 604800. The value of 'interval' would then be 604800.
     215 *
     216 * The 'display' is the description. For the 'weekly' key, the 'display' would
     217 * be <code>__('Once Weekly')</code>.
     218 *
     219 * For your plugin, you will be passed an array. you can easily add your
     220 * schedule by doing the following.
     221 * <code>
     222 * // filter parameter variable name is 'array'
     223 *  $array['weekly'] = array(
     224 *      'interval' => 604800,
     225 *      'display' => __('Once Weekly')
     226 *  );
     227 * </code>
     228 *
     229 * @since 2.1.0
     230 *
     231 * @return array
     232 */
    122233function wp_get_schedules() {
    123234    $schedules = array(
     
    129240}
    130241
     242/**
     243 * Retrieve Cron schedule for hook with arguments.
     244 *
     245 * @since 2.1.0
     246 *
     247 * @param callback $hook Function or method to call, when cron is run.
     248 * @param array $args Optional. Arguments to pass to the hook function.
     249 * @return string|bool False, if no schedule. Schedule on success.
     250 */
    131251function wp_get_schedule($hook, $args = array()) {
    132252    $crons = _get_cron_array();
     
    145265//
    146266
     267/**
     268 * Retrieve cron info array option.
     269 *
     270 * @since 2.1.0
     271 * @access private
     272 *
     273 * @return array CRON info array.
     274 */
    147275function _get_cron_array()  {
    148276    $cron = get_option('cron');
     
    158286}
    159287
     288/**
     289 * Updates the CRON option with the new CRON array.
     290 *
     291 * @since 2.1.0
     292 * @access private
     293 *
     294 * @param array $cron Cron info array from {@link _get_cron_array()}.
     295 */
    160296function _set_cron_array($cron) {
    161297    $cron['version'] = 2;
     
    163299}
    164300
     301/**
     302 * Upgrade a Cron info array.
     303 *
     304 * This function upgrades the Cron info array to version 2.
     305 *
     306 * @since 2.1.0
     307 * @access private
     308 *
     309 * @param array $cron Cron info array from {@link _get_cron_array()}.
     310 * @return array An upgraded Cron info array.
     311 */
    165312function _upgrade_cron_array($cron) {
    166313    if ( isset($cron['version']) && 2 == $cron['version'])
Note: See TracChangeset for help on using the changeset viewer.