| @@ -4,8 +4,12 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + exit( 0 ); | |
| 10 | +} | |
| 11 | + | |
| 8 | 12 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 9 | 13 | |
| 10 | 14 | /** |
| 11 | 15 | * VideoPress command line utilities. |
| @@ -57,23 +61,24 @@ | ||
| 57 | 61 | * wp videopress list_crons |
| 58 | 62 | */ |
| 59 | 63 | public function list_crons() { |
| 60 | 64 | |
| 61 | - $scheduler = VideoPress_Scheduler::init(); | |
| 62 | - $crons = $scheduler->get_crons(); | |
| 65 | + $scheduler = VideoPress_Scheduler::init(); | |
| 66 | + $crons = $scheduler->get_crons(); | |
| 67 | + $crons_count = is_countable( $crons ) ? count( $crons ) : 0; | |
| 63 | 68 | |
| 64 | 69 | $schedules = wp_get_schedules(); |
| 65 | 70 | |
| 66 | - if ( count( $crons ) === 0 ) { | |
| 71 | + if ( $crons_count === 0 ) { | |
| 67 | 72 | WP_CLI::success( __( 'Found no available cron jobs.', 'jetpack' ) ); |
| 68 | 73 | |
| 69 | 74 | } else { |
| 70 | 75 | /* translators: %d is the number of crons */ |
| 71 | - WP_CLI::success( sprintf( _n( 'Found %d available cron job.', 'Found %d available cron jobs.', count( $crons ), 'jetpack' ), count( $crons ) ) ); | |
| 76 | + WP_CLI::success( sprintf( _n( 'Found %d available cron job.', 'Found %d available cron jobs.', $crons_count, 'jetpack' ), $crons_count ) ); | |
| 72 | 77 | } |
| 73 | 78 | |
| 74 | 79 | foreach ( $crons as $cron_name => $cron ) { |
| 75 | - $interval = isset( $schedules[ $cron['interval'] ]['display'] ) ? $schedules[ $cron['interval'] ]['display'] : $cron['interval']; | |
| 80 | + $interval = $schedules[ $cron['interval'] ]['display'] ?? $cron['interval']; | |
| 76 | 81 | $runs_next = $scheduler->check_cron( $cron_name ); |
| 77 | 82 | $status = $runs_next ? sprintf( 'Scheduled - Runs Next at %s GMT', gmdate( 'Y-m-d H:i:s', $runs_next ) ) : 'Not Scheduled'; |
| 78 | 83 | |
| 79 | 84 | WP_CLI::log( 'Name: ' . $cron_name ); |