admin管理员组

文章数量:1134247

I'm using crontab to run a php script loaded with wp-load.php with absolute path.

However, when I go to maintenance mode, the file can't run. I'm using Coming soon plugin.

Is there a way to exclude the file and run it even in maintenance mode?

I'm using crontab to run a php script loaded with wp-load.php with absolute path.

However, when I go to maintenance mode, the file can't run. I'm using Coming soon plugin.

Is there a way to exclude the file and run it even in maintenance mode?

Share Improve this question edited Apr 19, 2019 at 9:49 Fayaz 8,9872 gold badges33 silver badges51 bronze badges asked Apr 19, 2019 at 6:09 Jean R.Jean R. 1112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It's been awhile since the moment of the question, but maybe a solution will help someone in the future.

Just define IS_WP_CLI variable in the beginning of your script .

...
define('IS_WP_CLI', true); // Avoid maintenance mode
require_once HOME_PATH . '/wp-load.php';
...

If IS_WP_CLI defined -> maintenance mode will not be instantiated.

if (defined('IS_WP_CLI')) { return ; }

Now you can run cli scripts even if maintenance mode is active.

本文标签: phpHow to bypass maintenance mode with external cron