Changeset 3697 for trunk/wp-includes/cron.php
- Timestamp:
- 04/06/2006 05:25:50 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/cron.php
-
Property
svn:eol-style
set to
native
r3636 r3697 1 1 <?php 2 function wp_schedule_single_event($timestamp, $hook) { 3 $args = array_slice(func_get_args(), 2); 4 $crons = get_option('cron'); 5 $crons[$timestamp][$hook] = array('schedule' => false, 'args' => $args); 6 ksort($crons); 7 update_option('cron', $crons); 8 } 9 function wp_schedule_event($timestamp, $recurrence, $hook) { 10 $args = array_slice(func_get_args(), 3); 11 $crons = get_option('cron'); 12 $schedules = wp_get_schedules(); 13 if(!isset($schedules[$recurrence])) 14 return false; 15 $crons[$timestamp][$hook] = array('schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval']); 16 ksort($crons); 17 update_option('cron', $crons); 2 3 function wp_schedule_single_event( $timestamp, $hook ) { 4 $args = array_slice( func_get_args(), 2 ); 5 $crons = get_option( 'cron' ); 6 $crons[$timestamp][$hook] = array( 'schedule' => false, 'args' => $args ); 7 ksort( $crons ); 8 update_option( 'cron', $crons ); 18 9 } 19 10 11 function wp_schedule_event( $timestamp, $recurrence, $hook ) { 12 $args = array_slice( func_get_args(), 3 ); 13 $crons = get_option( 'cron' ); 14 $schedules = wp_get_schedules(); 15 if ( !isset( $schedules[$recurrence] ) ) 16 return false; 17 $crons[$timestamp][$hook] = array( 'schedule' => $recurrence, 'args' => $args, 'interval' => $schedules[$recurrence]['interval'] ); 18 ksort( $crons ); 19 update_option( 'cron', $crons ); 20 } 20 21 21 function wp_reschedule_event( $timestamp, $recurrence, $hook) {22 $args = array_slice( func_get_args(), 3);23 $crons = get_option( 'cron');22 function wp_reschedule_event( $timestamp, $recurrence, $hook ) { 23 $args = array_slice( func_get_args(), 3 ); 24 $crons = get_option( 'cron' ); 24 25 $schedules = wp_get_schedules(); 25 26 $interval = 0; 26 27 27 28 // First we try to get it from the schedule 28 if ( 0 == $interval )29 if ( 0 == $interval ) 29 30 $interval = $schedules[$recurrence]['interval']; 30 31 // Now we try to get it from the saved interval in case the schedule disappears 31 if ( 0 == $interval )32 if ( 0 == $interval ) 32 33 $interval = $crons[$timestamp][$hook]['interval']; 33 34 // Now we assume something is wrong and fail to schedule 34 if ( 0 == $interval )35 if ( 0 == $interval ) 35 36 return false; 36 37 37 while ($timestamp < time() + 1) {38 while ( $timestamp < time() + 1 ) 38 39 $timestamp += $interval; 39 } 40 wp_schedule_event( $timestamp, $recurrence, $hook);40 41 wp_schedule_event( $timestamp, $recurrence, $hook ); 41 42 } 42 43 43 function wp_unschedule_event( $timestamp, $hook) {44 $crons = get_option( 'cron');45 unset( $crons[$timestamp][$hook]);44 function wp_unschedule_event( $timestamp, $hook ) { 45 $crons = get_option( 'cron' ); 46 unset( $crons[$timestamp][$hook] ); 46 47 if ( empty($crons[$timestamp]) ) 47 unset( $crons[$timestamp]);48 update_option( 'cron', $crons);48 unset( $crons[$timestamp] ); 49 update_option( 'cron', $crons ); 49 50 } 50 51 51 function wp_clear_scheduled_hook( $hook) {52 while ($timestamp = wp_next_scheduled($hook))53 wp_unschedule_event( $timestamp, $hook);52 function wp_clear_scheduled_hook( $hook ) { 53 while ( $timestamp = wp_next_scheduled( $hook ) ) 54 wp_unschedule_event( $timestamp, $hook ); 54 55 } 55 56 56 function wp_next_scheduled( $hook) {57 $crons = get_option( 'cron');57 function wp_next_scheduled( $hook ) { 58 $crons = get_option( 'cron' ); 58 59 if ( empty($crons) ) 59 60 return false; 60 foreach($crons as $timestamp => $cron) { 61 //if($timestamp <= time()) continue; 62 if(isset($cron[$hook])) return $timestamp; 63 } 61 foreach ( $crons as $timestamp => $cron ) 62 if ( isset( $cron[$hook] ) ) 63 return $timestamp; 64 64 return false; 65 65 } 66 66 67 67 function spawn_cron() { 68 if (array_shift(array_keys(get_option('cron'))) > time()) return; 69 70 $cron_url = get_settings('siteurl') . '/wp-cron.php'; 71 $parts = parse_url($cron_url); 72 73 $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01); 68 if ( array_shift( array_keys( get_option( 'cron' ) ) ) > time() ) 69 return; 70 71 $cron_url = get_settings( 'siteurl' ) . '/wp-cron.php'; 72 $parts = parse_url( $cron_url ); 73 74 $argyle = @ fsockopen( $parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01 ); 74 75 if ( $argyle ) 75 fputs( $argyle,76 fputs( $argyle, 76 77 "GET {$parts['path']}?check=" . md5(DB_PASS . '187425') . " HTTP/1.0\r\n" 77 78 . "Host: {$_SERVER['HTTP_HOST']}\r\n\r\n" … … 80 81 81 82 function wp_cron() { 82 $crons = get_option( 'cron');83 if ( !is_array($crons) || array_shift(array_keys($crons)) > time())83 $crons = get_option( 'cron' ); 84 if ( !is_array($crons) || array_shift( array_keys( $crons ) ) > time() ) 84 85 return; 85 86 86 87 $schedules = wp_get_schedules(); 87 foreach ( $crons as $timestamp => $cronhooks) {88 if ( $timestamp > time()) break;89 foreach ($cronhooks as $hook => $args) {90 if (isset($schedules[$hook]['callback']) && !call_user_func($schedules[$hook]['callback']))88 foreach ( $crons as $timestamp => $cronhooks ) { 89 if ( $timestamp > time() ) break; 90 foreach ( $cronhooks as $hook => $args ) { 91 if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) 91 92 continue; 92 93 spawn_cron(); … … 98 99 function wp_get_schedules() { 99 100 $schedules = array( 100 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly')),101 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily')),101 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ), 102 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ), 102 103 ); 103 return array_merge( apply_filters('cron_schedules', array()), $schedules);104 return array_merge( apply_filters( 'cron_schedules', array() ), $schedules ); 104 105 } 106 105 107 ?> -
Property
svn:eol-style
set to
Note: See TracChangeset
for help on using the changeset viewer.