Instantly share code, notes, and snippets.

What would you like to do?
Trigger for WP MU Cron [Wordpress]
if (!defined('ABSPATH')) {
require_once(dirname( __FILE__ ) . '/wp-load.php');
global $wpdb;
if ( is_multisite()) {
$sites = get_sites();
foreach ($sites as $site ) {
$blog_id = $site->blog_id;
//if ($blog_id < 6 ){//if we need certain blogs
switch_to_blog( $blog_id );
//here what we gonna do...
$site_url = get_site_url($blog_id);
$command = $site_url.'/publishing.php';
wp_remote_get( $command );
//}//endif $blog_id
sleep(3); // this should pause for 3 seconds for every loop
}//endif multisite

This comment has been minimized.

Copy link

andrewodri commented Jun 20, 2018

Just curious about the restore_current_blog(); call on line 17... Does this perform a necessary function, or could it be dropped to (minutely) improve performance?


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment