Many times I have code and I want to make sure it only runs in a cron context, or it never runs in a cron context.
Is there an is_cron_running
style function?
Many times I have code and I want to make sure it only runs in a cron context, or it never runs in a cron context.
Is there an is_cron_running
style function?
Yes, wp_doing_cron
will return true if the current request is a WP Cron request, or if it's triggered from WP CLI
https://developer.wordpress/reference/functions/wp_doing_cron/