wp_cron

Run scheduled callbacks or spawn cron for all scheduled events.

Description

wp_cron(); 

Usage

  1. if ( !function_exists( 'wp_cron' ) ) { 
  2. require_once ABSPATH . WPINC . '/cron.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_cron(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/cron.php  
  1. function wp_cron() { 
  2. // Prevent infinite loops caused by lack of wp-cron.php 
  3. if ( strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || ( defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ) ) 
  4. return; 
  5.  
  6. if ( false === $crons = _get_cron_array() ) 
  7. return; 
  8.  
  9. $gmt_time = microtime( true ); 
  10. $keys = array_keys( $crons ); 
  11. if ( isset($keys[0]) && $keys[0] > $gmt_time ) 
  12. return; 
  13.  
  14. $schedules = wp_get_schedules(); 
  15. foreach ( $crons as $timestamp => $cronhooks ) { 
  16. if ( $timestamp > $gmt_time ) break; 
  17. foreach ( (array) $cronhooks as $hook => $args ) { 
  18. if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) ) 
  19. continue; 
  20. spawn_cron( $gmt_time ); 
  21. break 2;