Skip to content

Instantly share code, notes, and snippets.

@sabrina-zeidan sabrina-zeidan/trigger.php
Last active Jun 20, 2018

Embed
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 );
wp_suspend_cache_addition(true);
//here what we gonna do...
$site_url = get_site_url($blog_id);
$command = $site_url.'/publishing.php';
wp_remote_get( $command );
wp_suspend_cache_addition(false);
restore_current_blog();
//}//endif $blog_id
sleep(3); // this should pause for 3 seconds for every loop
}//endforeach
}//endif multisite
@andrewodri

This comment has been minimized.

Copy link

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?

Thanks!

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.