Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.
$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
You can’t perform that action at this time.