A simple script, intended to be run in the context of a WordPress install -- `wp-cli`'s `eval-file` is the easiest way -- to ping the cron of all sites registered in the network.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$start_date = date_i18n('Y/m/d H:i:s'); | |
$start_time = microtime(true); | |
echo "Start site-wide wp-cron at $start_date\n"; | |
$sites = wp_get_sites(); | |
foreach ($sites as $site) { | |
$url = "http://" . $site['domain'] . $site['path']; | |
echo "Ping wp-cron.php for `$url` ... "; | |
file_get_contents($url . 'wp-cron.php'); | |
echo "OK.\n"; | |
} | |
$end_time = microtime(true); | |
$end_date = date_i18n('Y/m/d H:i:s'); | |
$time = ($end_time - $start_time); | |
echo "Finished at $end_date ($time s)\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment