Created
January 29, 2012 23:04
-
-
Save jonyesno/1701258 to your computer and use it in GitHub Desktop.
Loop over WordPress MU (aka Network) sites, calling a script on each via HTTP
This file contains hidden or 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 | |
/* example use: http://example.com/wpmu-loop.php?script=wp-fixup-tags.php */ | |
/* see also: https://gist.github.com/1645313 */ | |
define('WP_INSTALLING', true); | |
require_once('wp-load.php'); | |
/* get_blogs() only knows about sub-domain blogs, not sub-directory blogs | |
it's probably just a case of appending the path column to the result */ | |
function get_blogs() { | |
global $wpdb; | |
$query = "SELECT domain from wp_blogs"; | |
$blogs = $wpdb->get_results($query, ARRAY_N); | |
return($blogs); | |
} | |
$blogs = get_blogs(); | |
print "<pre>\n"; | |
if ($blogs) { | |
print "blogs: " . count($blogs) . "\n"; | |
foreach ($blogs as $blog) { | |
print $blog[0] . "\n"; | |
ob_flush(); | |
if (!empty($_GET['script'])) { | |
print file_get_contents("http://" . $blog[0] . "/" . $_GET['script']); | |
print "\n"; | |
ob_flush(); | |
} | |
} | |
} | |
print "</pre>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment