Or something like that. That info is set on every page and yet is ridiculously difficlut (or hidden) as to how to go about this.
I have seen it mentioned to use:
global $blog_id;
echo $blog_id;
The problem is that calling this in the wrong place screws up that global variable. For instance, i tried using it in a function sent to 'init' and it messed things up.
Just the fact that is a very generic term (my first choice when I was defining a blog id) makes it super easy for a theme or plugin to mess things up.
You can use:
global $wpdb;
$current_blog_id = $wpdb->blogid;
This is better, but still awkward.
Or, it appears it is also stored in the actual $GLOBALS like so...
$current_blog_id = $GLOBALS['blog_id'];
Most of the time, $blog_id is just being set by $GLOBALS['blog_id'] or $wpdb->id; anyway.
But the definition all of these id's seem to just loop around on each other in the code. At times $GLOBALS is set by $blog_id, at times the other way around. At times, $current_blog->id is set by $blog_id, some times the reverse.
Obviously it is all working, but it should be easier to figure out the id of the blog we are currently on.
I searched the entire code base of mu and the beta 3.0 and that wording 'current_blog_id' is not used anywhere.
function current_blog_id() {
global $wpdb;
return $wpdb->blogid;
}
Would save a lot of headaches. :)