Skip to content

Instantly share code, notes, and snippets.

@bolstad
Created April 4, 2012 08:07
Show Gist options
  • Save bolstad/2299616 to your computer and use it in GitHub Desktop.
Save bolstad/2299616 to your computer and use it in GitHub Desktop.
<?php
echo "memory use: " . memory_get_usage() . "\n";
$configdir = __FILE__;
$configdir = preg_replace('|wp-content\/.*|','',$configdir);
$configdir .= 'wp-load.php';
error_reporting(E_ALL);
ini_set('display_errors','On');
ini_set('display_startup_errors','On');
// set some required variables if running from cli
if (empty($_SERVER['HTTP_HOST']))
{
$_SERVER["SERVER_NAME"] = "localhost";
$_SERVER["HTTP_HOST"] = '127.0.0.1';
$_SERVER["SERVER_PROTOCOL"] = 'HTTP/1.1';
$_SERVER["HTTP_USER_AGENT"] = "fake agent";
$_SERVER["HTTP_ACCEPT"] = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,video/x-mng,image/png,image/jpeg,image/gif;q=0.2,text/css,*/*;q=0.1";
}
echo "Loading: $configdir\n";
if (file_exists($configdir))
include("$configdir");
else
die ("Can not load $configdir\n");
if (function_exists('switch_to_blog'))
{
global $wpdb;
$blogs = $wpdb->get_col( $wpdb->prepare( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id DESC LIMIT %d,5", $c ) );
foreach( $blogs as $blog ) {
if( $blog != $tags_blog_id ) {
$details = get_blog_details( $blog );
print_r($details);
switch_to_blog($details->blog_id);
}
$c++;
}
}
echo "memory use: " . memory_get_usage() . "\n";
echo "Done!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment