1 | <?php
|
---|
2 | /**
|
---|
3 | * WordPress Cron Implementation for hosts, which do not offer CRON or for which
|
---|
4 | * the user has not setup a CRON job pointing to this file.
|
---|
5 | *
|
---|
6 | * The HTTP request to this file will not slow down the visitor who happens to
|
---|
7 | * visit when the cron job is needed to run.
|
---|
8 | *
|
---|
9 | * @package WordPress
|
---|
10 | */
|
---|
11 |
|
---|
12 | ignore_user_abort(true);
|
---|
13 |
|
---|
14 | if ( !empty($_POST) || defined('DOING_AJAX') || defined('DOING_CRON') )
|
---|
15 | die();
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Tell WordPress we are doing the CRON task.
|
---|
19 | *
|
---|
20 | * @var bool
|
---|
21 | */
|
---|
22 | define('DOING_CRON', true);
|
---|
23 |
|
---|
24 | if ( !defined('ABSPATH') ) {
|
---|
25 | /** Setup WordPress environment */
|
---|
26 | require_once('./wp-load.php');
|
---|
27 | }
|
---|
28 |
|
---|
29 | if ( false === $crons = _get_cron_array() )
|
---|
30 | die();
|
---|
31 |
|
---|
32 | $keys = array_keys( $crons );
|
---|
33 | $local_time = time();
|
---|
34 |
|
---|
35 | if ( isset($keys[0]) && $keys[0] > $local_time )
|
---|
36 | die();
|
---|
37 |
|
---|
38 | foreach ($crons as $timestamp => $cronhooks) {
|
---|
39 | if ( $timestamp > $local_time )
|
---|
40 | break;
|
---|
41 |
|
---|
42 | foreach ($cronhooks as $hook => $keys) {
|
---|
43 |
|
---|
44 | foreach ($keys as $k => $v) {
|
---|
45 |
|
---|
46 | $schedule = $v['schedule'];
|
---|
47 |
|
---|
48 | if ($schedule != false) {
|
---|
49 | $new_args = array($timestamp, $schedule, $hook, $v['args']);
|
---|
50 | call_user_func_array('wp_reschedule_event', $new_args);
|
---|
51 | }
|
---|
52 |
|
---|
53 | wp_unschedule_event($timestamp, $hook, $v['args']);
|
---|
54 |
|
---|
55 | do_action_ref_array($hook, $v['args']);
|
---|
56 | }
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | die();
|
---|