Changeset 8806
- Timestamp:
- 09/04/2008 07:12:40 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cron.php
r8572 r8806 1 1 <?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 */ 3 22 function wp_schedule_single_event( $timestamp, $hook, $args = array()) { 4 23 $crons = _get_cron_array(); … … 9 28 } 10 29 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 */ 11 45 function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array()) { 12 46 $crons = _get_cron_array(); … … 20 54 } 21 55 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 */ 22 67 function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array()) { 23 68 $crons = _get_cron_array(); … … 42 87 } 43 88 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 */ 44 101 function wp_unschedule_event( $timestamp, $hook, $args = array() ) { 45 102 $crons = _get_cron_array(); … … 53 110 } 54 111 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 */ 55 120 function wp_clear_scheduled_hook( $hook ) { 56 121 $args = array_slice( func_get_args(), 1 ); … … 60 125 } 61 126 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 */ 62 136 function wp_next_scheduled( $hook, $args = array() ) { 63 137 $crons = _get_cron_array(); … … 77 151 * @since 2.1.0 78 152 * 79 * @return null C RONcould 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. 80 154 */ 81 155 function spawn_cron() { … … 94 168 } 95 169 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 */ 96 177 function wp_cron() { 97 178 // Prevent infinite loops caused by lack of wp-cron.php … … 120 201 } 121 202 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 */ 122 233 function wp_get_schedules() { 123 234 $schedules = array( … … 129 240 } 130 241 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 */ 131 251 function wp_get_schedule($hook, $args = array()) { 132 252 $crons = _get_cron_array(); … … 145 265 // 146 266 267 /** 268 * Retrieve cron info array option. 269 * 270 * @since 2.1.0 271 * @access private 272 * 273 * @return array CRON info array. 274 */ 147 275 function _get_cron_array() { 148 276 $cron = get_option('cron'); … … 158 286 } 159 287 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 */ 160 296 function _set_cron_array($cron) { 161 297 $cron['version'] = 2; … … 163 299 } 164 300 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 */ 165 312 function _upgrade_cron_array($cron) { 166 313 if ( isset($cron['version']) && 2 == $cron['version'])
Note: See TracChangeset
for help on using the changeset viewer.