AI Verified

Name

Multi Site - Run Crons

About

The Multisite Cron Executor is a streamlined WordPress plugin designed for efficient management of WP-Cron jobs across a multisite network. It automates the execution of cron jobs on each site, ensuring consistent performance and timely task handling without the need for manual intervention.

Language

PHP

Rating

Voted: 0 by 0 user(s)

Codevault

KasperStuck

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: 6.4

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

24/01/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Multi Site - Run Crons

 
                    
1if (is_multisite()) {
2 // Retrieve all sites in the multisite network
3 $sites = get_sites();
4 
5 // Loop through each site in the network
6 foreach ($sites as $site) {
7 // Get the ID of the current site in the loop
8 $blogId = $site->blog_id;
9 
10 // Switch the context to the current site
11 switch_to_blog($blogId);
12 
13 // Temporarily suspend cache additions
14 wp_suspend_cache_addition(true);
15 
16 // Get the URL of the site
17 $siteUrl = get_site_url($blogId);
18 
19 // Create the command to call the wp-cron.php for the site
20 $command = $siteUrl . '/wp-cron.php?doing_wp_cron';
21 
22 // Execute a HTTP GET request to the wp-cron.php URL
23 wp_remote_get($command);
24 
25 // Resume cache additions
26 wp_suspend_cache_addition(false);
27 
28 // Restore the context to the main site
29 restore_current_blog();
30 }
31}// PHP and WordPress, nothing else!
32// Check if WordPress is in multisite mode
33if (is_multisite()) {
34 // Retrieve all sites in the multisite network
35 $sites = get_sites();
36 
37 // Loop through each site in the network
38 foreach ($sites as $site) {
39 // Get the ID of the current site in the loop
40 $blogId = $site->blog_id;
41 
42 // Switch the context to the current site
43 switch_to_blog($blogId);
44 
45 // Temporarily suspend cache additions
46 wp_suspend_cache_addition(true);
47 
48 // Get the URL of the site
49 $siteUrl = get_site_url($blogId);
50 
51 // Create the command to call the wp-cron.php for the site
52 $command = $siteUrl . '/wp-cron.php?doing_wp_cron';
53 
54 // Execute a HTTP GET request to the wp-cron.php URL
55 wp_remote_get($command);
56 
57 // Resume cache additions
58 wp_suspend_cache_addition(false);
59 
60 // Restore the context to the main site
61 restore_current_blog();
62 }
63}// PHP and WordPress, nothing else!
64if (is_multisite()) {
65 // Retrieve all sites in the multisite network
66 $sites = get_sites();
67 
68 // Loop through each site in the network
69 foreach ($sites as $site) {
70 // Get the ID of the current site in the loop
71 $blogId = $site->blog_id;
72 
73 // Switch the context to the current site
74 switch_to_blog($blogId);
75 
76 // Temporarily suspend cache additions
77 wp_suspend_cache_addition(true);
78 
79 // Get the URL of the site
80 $siteUrl = get_site_url($blogId);
81 
82 // Create the command to call the wp-cron.php for the site
83 $command = $siteUrl . '/wp-cron.php?doing_wp_cron';
84 
85 // Execute a HTTP GET request to the wp-cron.php URL
86 wp_remote_get($command);
87 
88 // Resume cache additions
89 wp_suspend_cache_addition(false);
90 
91 // Restore the context to the main site
92 restore_current_blog();
93 }
94}// PHP and WordPress, nothing else!
95// Check if WordPress is in multisite mode
96if (is_multisite()) {
97 // Retrieve all sites in the multisite network
98 $sites = get_sites();
99 
100 // Loop through each site in the network
101 foreach ($sites as $site) {
102 // Get the ID of the current site in the loop
103 $blogId = $site->blog_id;
104 
105 // Switch the context to the current site
106 switch_to_blog($blogId);
107 
108 // Temporarily suspend cache additions
109 wp_suspend_cache_addition(true);
110 
111 // Get the URL of the site
112 $siteUrl = get_site_url($blogId);
113 
114 // Create the command to call the wp-cron.php for the site
115 $command = $siteUrl . '/wp-cron.php?doing_wp_cron';
116 
117 // Execute a HTTP GET request to the wp-cron.php URL
118 wp_remote_get($command);
119 
120 // Resume cache additions
121 wp_suspend_cache_addition(false);
122 
123 // Restore the context to the main site
124 restore_current_blog();
125 }
126}

0

Related Snippets

Please see some snippets below related to this snippet..

WordPress Admin

AI Verified

1

Save in WP Admin with CTRL + S

Added: 2 years ago

Last Updated: 4 months ago

Save time by hitting CTRL/CMD + S instead of scrolling to find the Save/Update/Publish button

WordPress Admin

AI Verified

0

Custom Color Key

Added: 9 months ago

Last Updated: 9 months ago

Adds a color-coded key at the top of specific admin page.

WordPress Admin

AI Verified

0

Remove jQuery Migrate

Added: 1 year ago

Last Updated: 1 year ago

Remove jQuery Migrate

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

0

Woo 404 Redirect Optimizer

Added: 7 months ago

Last Updated: 7 months ago

WordPress Admin

AI Verified

0

Multi Site - Run Crons

Added: 7 months ago

Last Updated: 7 months ago

The Multisite Cron Executor is a streamlined WordPress plugin designed for efficient management of WP-Cron jobs across a multisite network. It automates the execution of cron jobs on each site, ensuri...