Created
July 14, 2014 20:11
-
-
Save EdHurtig/a1276d0153f9a42387f1 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Loops through all the blogs in the network switching blogs and calling the given function with a single site returned from wp_get_sites | |
* | |
* | |
* @param callable $lambda A function to execute for every single blog on the network | |
*/ | |
function foreach_blog( $lambda ) { | |
$blogs = wp_get_sites( array( 'limit' => false ) ); | |
foreach ( $blogs as $blog ) { | |
switch_to_blog( $blog['blog_id'] ); | |
$lambda( $blog ); | |
restore_current_blog(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great for Debugging, fixing, and maintaining multisite networks