Running WP Cron on multisite the right way

I think the best way is to use WP-CLI but you’d need to write a bash script to do this. Here is one that should do it for you: WP_PATH=”/path/to/wp” for SITE_URL in = $(wp site list –fields=domain,path,archived,deleted –format=csv –path=”$WP_PATH” | grep “,0,0$” | awk -F ‘,’ ‘{print $1 $2}’) do for EVENT_HOOK in $(wp … Read more

Detect if WP is running under WP-CLI

Within the php/wp-cli.php we find these lines: // Can be used by plugins/themes to check if WP-CLI is running or not define( ‘WP_CLI’, true ); define( ‘WP_CLI_VERSION’, trim( file_get_contents( WP_CLI_ROOT . ‘/VERSION’ ) ) ); define( ‘WP_CLI_START_MICROTIME’, microtime( true ) ); so you could check if WP_CLI or WP_CLI_VERSION are defined.