Skip to content

Instantly share code, notes, and snippets.

@tlovett1
Created August 30, 2012 14:46
Show Gist options
  • Save tlovett1/3529947 to your computer and use it in GitHub Desktop.
Save tlovett1/3529947 to your computer and use it in GitHub Desktop.
Alternative function to get_blogs_list
function tup_get_blogs_info() {
if ( ( $results = get_site_option( '_blogs_info_list' ) ) === false ) {
global $wpdb;
$results = $wpdb->get_results( 'SELECT blog_id, path, domain FROM ' . $wpdb->blogs, ARRAY_A );
foreach ( $results as &$result ) {
switch_to_blog( $result['blog_id'] );
$site_info = $wpdb->get_results( 'SELECT option_value FROM ' . $wpdb->options . " WHERE option_name = 'blogname' ", ARRAY_A );
restore_current_blog();
if ( is_array( $site_info ) && is_array( $site_info[0] ) )
$result['blogname'] = $site_info[0]['option_value'];
}
update_site_option( '_blogs_info_list', $results );
}
return $results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment