From ea9b83a0239c38f952bceec1775e2151f5153c4e Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Tue, 26 Apr 2016 16:35:43 -0700 Subject: [PATCH] Define `DOING_CRON` before WordPress is loaded Some plugins make use of this constant to conditionally load code, which is a valid use case we should do our best to accommodate. --- php/WP_CLI/Runner.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index b8ec97b773..8d13f2690c 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -747,6 +747,10 @@ public function start() { define( 'WP_IMPORTING', true ); } + if ( $this->cmd_starts_with( array( 'cron', 'event', 'run' ) ) ) { + define( 'DOING_CRON', true ); + } + if ( $this->cmd_starts_with( array( 'plugin' ) ) ) { $GLOBALS['pagenow'] = 'plugins.php'; }