Changeset 3512
- Timestamp:
- 02/11/2006 02:24:47 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r3511 r3512 2318 2318 } 2319 2319 2320 function wp_schedule_event($timestamp, $recurrence, $hook) { 2321 $args = array_slice(func_get_args(), 3); 2322 $crons = get_option('cron'); 2323 $crons[$timestamp][$hook] = array('recur' => $recurrence, 'args' => $args); 2324 ksort($crons); 2325 update_option('cron', $crons); 2326 } 2327 2328 function wp_unschedule_event($timestamp, $hook) { 2329 $crons = get_option('cron'); 2330 unset($crons[$timestamp][$hook]); 2331 if ( empty($crons[$timestamp]) ) 2332 unset($crons[$timestamp]); 2333 update_option('cron', $crons); 2334 } 2335 2336 function wp_clear_scheduled_hook($hook) { 2337 while($timestamp = next_scheduled('scheduled_hook')) 2338 wp_unschedule_event($timestamp, 'scheduled_hook'); 2339 } 2340 2341 function next_scheduled($hook) { 2342 $crons = get_option('cron'); 2343 if ( empty($crons) ) 2344 return false; 2345 foreach($crons as $timestamp => $cron) { 2346 //if($timestamp <= time()) continue; 2347 if(isset($cron[$hook])) return $timestamp; 2348 } 2349 return false; 2350 } 2351 2352 function spawn_cron() { 2353 if (array_shift(array_keys(get_option('cron'))) > time()) return; 2354 2355 $cron_url = get_settings('siteurl') . '/wp-cron.php'; 2356 $parts = parse_url($cron_url); 2357 $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); 2358 if ( $argyle ) 2359 fputs($argyle, "GET {$parts['path']}?time=" . time() . '&check=' 2360 . md5(DB_PASS . '187425') . " HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n"); 2361 } 2362 2363 function wp_cron() { 2364 if (array_shift(array_keys(get_option('cron'))) > time()) 2365 return; 2366 2367 $crons = get_option('cron'); 2368 $newcrons = $crons; 2369 foreach ($crons as $timestamp => $cronhooks) { 2370 if ($timestamp > time()) break; 2371 foreach($cronhooks as $hook => $args) { 2372 do_action($hook, $args['args']); 2373 $recurrence = $args['recur']; 2374 if ( 'hourly' == $recurrence ) { 2375 $args = array_merge( array($timestamp + 3600, $recurrence, $hook), $args['args']); 2376 call_user_func_array('wp_schedule_event', $args); 2377 } else if ( 'daily' == $recurrence ) { 2378 $args = array_merge( array($timestamp + 86400, $recurrence, $hook), $args['args']); 2379 call_user_func_array('wp_schedule_event', $args); 2380 } 2381 2382 wp_unschedule_event($timestamp, $hook); 2383 } 2384 } 2385 } 2386 2320 2387 ?>
Note: See TracChangeset
for help on using the changeset viewer.