-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathCron.php
More file actions
41 lines (34 loc) · 758 Bytes
/
Cron.php
File metadata and controls
41 lines (34 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace WP_CLI\Doctor\Check;
use WP_CLI;
use WP_CLI\Doctor\Check;
abstract class Cron extends Check {
/**
* @var array<array<string, mixed>>|null
*/
protected static $crons;
/**
* @return array<array<string, mixed>>
*/
protected static function get_crons() {
if ( isset( self::$crons ) ) {
return self::$crons;
}
ob_start();
WP_CLI::run_command(
array( 'cron', 'event', 'list' ),
array(
'format' => 'json',
'fields' => 'hook,args',
)
);
$ret = ob_get_clean();
$decoded = ! empty( $ret ) ? json_decode( $ret, true ) : array();
if ( ! is_array( $decoded ) ) {
$decoded = array();
}
/** @var array<array<string, mixed>> $decoded */
self::$crons = $decoded;
return self::$crons;
}
}