Ticket #5637: cron.phpdoc.r6603.diff

File cron.phpdoc.r6603.diff, 6.1 KB (added by hansengel, 4 years ago)

Almost-finished documentation of cron.php

  • wp-includes/cron.php

     
    11<?php 
    22 
     3/** 
     4 * wp_schedule_single_event() - Schedule a one-time event via cron 
     5 * 
     6 * Schedules a hook which will be executed once by the Wordpress actions core at a time which you 
     7 * specify. The action will fire off when someone visits your WordPress site, if the schedule time 
     8 * has passed. 
     9 * 
     10 * @since 2.1.0 
     11 * 
     12 * @param int $timestamp UNIX timestamp of when the event should occur 
     13 * @param string $hook The name of an action hook to execute 
     14 * @param array $args optional Arguments to pass to the hook function(s) 
     15 */ 
    316function wp_schedule_single_event( $timestamp, $hook, $args = array()) { 
    417        $crons = _get_cron_array(); 
    518        $key = md5(serialize($args)); 
     
    821        _set_cron_array( $crons ); 
    922} 
    1023 
     24/** 
     25 * wp_schedule_event() - Schedule a periodic event 
     26 * 
     27 * Schedules a hook which will be executed by the WordPress actions core on a specific interval, 
     28 * specified by you. The action will trigger when someone visits your WordPress site, if the 
     29 * scheduled time has passed. 
     30 * 
     31 * @since 2.1.0 
     32 * 
     33 * @param int $timestamp UNIX timestamp of the first time the event should occur 
     34 * @param string $recurrence How often the event should recur 
     35 * @param string $hook The name of an action hook to execute 
     36 * @param array $args optional Arguments to pass to the hook function(s) 
     37 */ 
    1138function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { 
    1239        $crons = _get_cron_array(); 
    1340        $schedules = wp_get_schedules(); 
     
    1946        _set_cron_array( $crons ); 
    2047} 
    2148 
     49/** 
     50 * wp_reschedule_event() - Reschedule a recurring event 
     51 * 
     52 * @since 2.1.0 
     53 * 
     54 * @param int $timestamp UNIX timestamp to reschedule to 
     55 * @param string $recurrence How often the event should recur 
     56 * @param string $hook The name of an action hook to execute 
     57 * @param array $args optional Arguments to pass to the hook function(s) 
     58 */ 
    2259function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) { 
    2360        $crons = _get_cron_array(); 
    2461        $schedules = wp_get_schedules(); 
     
    4178        wp_schedule_event( $timestamp, $recurrence, $hook, $args ); 
    4279} 
    4380 
     81/** 
     82 * wp_unschedule_event() - Unschedule a previously-scheduled cron job 
     83 * 
     84 * The $timestamp and $hook parameters are required so that the event can be identified. 
     85 * 
     86 * @since 2.1.0 
     87 * 
     88 * @param int $timestamp UNIX timestamp of the next occurence when the scheduled hook was set to run 
     89 * @param string $hook The name of an action hook for the event 
     90 * @param array $args optional Arguments to pass to the hook function(s) 
     91 */ 
    4492function wp_unschedule_event( $timestamp, $hook, $args = array() ) { 
    4593        $crons = _get_cron_array(); 
    4694        $key = md5(serialize($args)); 
     
    52100        _set_cron_array( $crons ); 
    53101} 
    54102 
     103/** 
     104 * wp_clear_scheduled_hook() - Unschedule all cron jobs attached to a specific hook 
     105 * 
     106 * @since 2.1.0 
     107 * 
     108 * @param string $hook The name of an action hook 
     109 */ 
    55110function wp_clear_scheduled_hook( $hook ) { 
    56111        $args = array_slice( func_get_args(), 1 ); 
    57112 
     
    59114                wp_unschedule_event( $timestamp, $hook, $args ); 
    60115} 
    61116 
     117/** 
     118 * wp_next_scheduled() - Return the next timestamp for a cron event 
     119 * 
     120 * @since 2.1.0 
     121 * 
     122 * @param string $hook Name of the action hook. 
     123 * @param array $args optional Arguments to pass to the hook function(s) 
     124 * @return int The UNIX timestamp of the next time the scheduled event will occur 
     125 */ 
    62126function wp_next_scheduled( $hook, $args = array() ) { 
    63127        $crons = _get_cron_array(); 
    64128        $key = md5(serialize($args)); 
     
    71135        return false; 
    72136} 
    73137 
     138/** 
     139 * spawn_cron() - {@internal Missing Short Description}} 
     140 * 
     141 * {@internal Missing Long Description}} 
     142 * 
     143 * @since 2.1.0 
     144 * 
     145 * @return unknown 
     146 */ 
    74147function spawn_cron() { 
    75148        $crons = _get_cron_array(); 
    76149 
     
    104177                ); 
    105178} 
    106179 
     180/** 
     181 * wp_cron() - {@internal Missing Short Description}} 
     182 * 
     183 * {@internal Missing Long Description}} 
     184 * 
     185 * @since 2.1.0 
     186 */ 
    107187function wp_cron() { 
    108188        // Prevent infinite loops caused by lack of wp-cron.php 
    109189        if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false ) 
     
    130210        } 
    131211} 
    132212 
     213/** 
     214 * wp_get_schedules() - {@internal Missing Short Description}} 
     215 * 
     216 * {@internal Missing Long Description}} 
     217 * 
     218 * @since 2.1.0 
     219 */ 
    133220function wp_get_schedules() { 
    134221        $schedules = array( 
    135222                'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ), 
     
    138225        return array_merge( apply_filters( 'cron_schedules', array() ), $schedules ); 
    139226} 
    140227 
     228/** 
     229 * wp_get_schedule() - {@internal Missing Short Description}} 
     230 * 
     231 * {@internal Missing Long Description}} 
     232 * 
     233 * @since 2.1.0 
     234 * 
     235 * @param string $hook The name of an action hook 
     236 * @param array $args optional Arguments to pass to the hook function(s) 
     237 * @return string|bool 
     238 */ 
    141239function wp_get_schedule($hook, $args = array()) { 
    142240        $crons = _get_cron_array(); 
    143241        $key = md5(serialize($args)); 
     
    154252// Private functions 
    155253// 
    156254 
     255/** 
     256 * _get_cron_array() - {@internal Missing Short Description}} 
     257 * 
     258 * {@internal Missing Long Description} 
     259 * 
     260 * @since 2.1.0 
     261 * @access private 
     262 * 
     263 * @return unknown 
     264 */ 
    157265function _get_cron_array()  { 
    158266        $cron = get_option('cron'); 
    159267        if ( ! is_array($cron) ) 
     
    167275        return $cron; 
    168276} 
    169277 
     278/** 
     279 * set_cron_array() - {@internal Missing Short Description}} 
     280 * 
     281 * {@internal Missing Long Description}} 
     282 * 
     283 * @since 2.1.0 
     284 * @access private 
     285 * 
     286 * @param array $cron Cron info array from _get_cron_array() 
     287 */ 
    170288function _set_cron_array($cron) { 
    171289        $cron['version'] = 2; 
    172290        update_option( 'cron', $cron ); 
    173291} 
    174292 
     293/** 
     294 * _update_cron_array() - Upgrade a Cron info array 
     295 * 
     296 * This function upgrades the Cron info array to version 2. 
     297 * 
     298 * @since 2.1.0 
     299 * @access private 
     300 * 
     301 * @param array $cron Cron info array from _get_cron_array() 
     302 * @return array An upgraded Cron info array 
     303 */ 
    175304function _upgrade_cron_array($cron) { 
    176305        if ( isset($cron['version']) && 2 == $cron['version']) 
    177306                return $cron; 
     
    190319        return $new_cron; 
    191320} 
    192321 
    193 ?> 
     322?> 
     323 No newline at end of file