$cron _get_cron_array() result (timestamp => hooks). * @param int $now Current time. * @param bool $disabled DISABLE_WP_CRON. * @return Result[] */ public static function evaluate( array $cron, int $now, bool $disabled ): array { $overdue = 0; $oldest = 0; foreach ( $cron as $timestamp => $hooks ) { $timestamp = (int) $timestamp; if ( $timestamp > 0 && $timestamp < $now - self::GRACE_SECONDS && is_array( $hooks ) ) { foreach ( $hooks as $events ) { $overdue += is_array( $events ) ? count( $events ) : 1; } $oldest = max( $oldest, $now - $timestamp ); } } $results = array(); if ( $overdue > 0 ) { $results[] = new Result( 'cron.overdue', $oldest >= self::CRITICAL_SECONDS ? Result::CRITICAL : Result::RECOMMENDED, /* translators: %d: number of scheduled tasks */ sprintf( _n( '%d scheduled task is overdue', '%d scheduled tasks are overdue', $overdue, 'keepwatch' ), $overdue ), $disabled ? __( 'WP-Cron is disabled on this site. Make sure a server cron job calls wp-cron.php regularly.', 'keepwatch' ) : __( 'WP-Cron runs when someone visits the site. On low-traffic sites, a server cron job keeps tasks on time.', 'keepwatch' ) ); } elseif ( $disabled ) { $results[] = new Result( 'cron.disabled', Result::GOOD, __( 'Scheduled tasks run on time (server cron)', 'keepwatch' ), __( 'WP-Cron is disabled and tasks are not falling behind, so a server cron job appears to be working.', 'keepwatch' ) ); } else { $results[] = new Result( 'cron.overdue', Result::GOOD, __( 'Scheduled tasks run on time', 'keepwatch' ) ); } return $results; } }