<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16050] trunk: get_current_blog_id().</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16050">16050</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-10-28 15:46:11 +0000 (Thu, 28 Oct 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>get_current_blog_id(). Props aaroncampbell. fixes <a href="http://trac.wordpress.org/ticket/15233">#15233</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpappphp">trunk/wp-app.php</a></li>
<li><a href="#trunkwpincludesadminbaradminbarclassphp">trunk/wp-includes/admin-bar/admin-bar-class.php</a></li>
<li><a href="#trunkwpincludesgeneraltemplatephp">trunk/wp-includes/general-template.php</a></li>
<li><a href="#trunkwpincludespostphp">trunk/wp-includes/post.php</a></li>
<li><a href="#trunkwpincludesuserphp">trunk/wp-includes/user.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpappphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-app.php (16049 => 16050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-app.php        2010-10-28 15:30:39 UTC (rev 16049)
+++ trunk/wp-app.php        2010-10-28 15:46:11 UTC (rev 16050)
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx">          * @since 2.2.0
</span><span class="cx">          */
</span><span class="cx">         function create_post() {
</span><del>-                global $blog_id, $user_ID;
</del><ins>+                global $user_ID;
</ins><span class="cx">                 $this-&gt;get_accepted_content_type($this-&gt;atom_content_types);
</span><span class="cx"> 
</span><span class="cx">                 $parser = new AtomParser();
</span><span class="lines">@@ -419,7 +419,7 @@
</span><span class="cx">                 if ( !current_user_can($cap) )
</span><span class="cx">                         $this-&gt;auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
</span><span class="cx"> 
</span><del>-                $blog_ID = (int ) $blog_id;
</del><ins>+                $blog_ID = get_current_blog_id();
</ins><span class="cx">                 $post_status = ($publish) ? 'publish' : 'draft';
</span><span class="cx">                 $post_author = (int) $user_ID;
</span><span class="cx">                 $post_title = $entry-&gt;title[1];
</span></span></pre></div>
<a id="trunkwpincludesadminbaradminbarclassphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/admin-bar/admin-bar-class.php (16049 => 16050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/admin-bar/admin-bar-class.php        2010-10-28 15:30:39 UTC (rev 16049)
+++ trunk/wp-includes/admin-bar/admin-bar-class.php        2010-10-28 15:46:11 UTC (rev 16050)
</span><span class="lines">@@ -7,8 +7,6 @@
</span><span class="cx">         var $user;
</span><span class="cx"> 
</span><span class="cx">         function initialize() {
</span><del>-                global $blog_id;
-
</del><span class="cx">                 /* Only load super admin menu code if the logged in user is a super admin */
</span><span class="cx">                 if ( is_super_admin() ) {
</span><span class="cx">                         require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' );
</span><span class="lines">@@ -28,7 +26,7 @@
</span><span class="cx">                         $this-&gt;user-&gt;domain = empty( $this-&gt;user-&gt;active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this-&gt;user-&gt;active_blog-&gt;blog_id ) );
</span><span class="cx">                         $this-&gt;user-&gt;account_domain = $this-&gt;user-&gt;domain;
</span><span class="cx">                 } else {
</span><del>-                        $this-&gt;user-&gt;active_blog = $this-&gt;user-&gt;blogs[$blog_id];
</del><ins>+                        $this-&gt;user-&gt;active_blog = $this-&gt;user-&gt;blogs[get_current_blog_id()];
</ins><span class="cx">                         $this-&gt;user-&gt;domain = trailingslashit( home_url() );
</span><span class="cx">                         $this-&gt;user-&gt;account_domain = $this-&gt;user-&gt;domain;
</span><span class="cx">                 }
</span><span class="lines">@@ -85,7 +83,7 @@
</span><span class="cx">         function remove_menu( $id ) {
</span><span class="cx">                 return $this-&gt;remove_node( $id, $this-&gt;menu );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function render() {
</span><span class="cx">                 ?&gt;
</span><span class="cx">                 &lt;div id=&quot;wpadminbar&quot; class=&quot;snap_nopreview no-grav&quot;&gt;
</span></span></pre></div>
<a id="trunkwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/general-template.php (16049 => 16050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/general-template.php        2010-10-28 15:30:39 UTC (rev 16049)
+++ trunk/wp-includes/general-template.php        2010-10-28 15:46:11 UTC (rev 16050)
</span><span class="lines">@@ -492,6 +492,18 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Retrieve the current blog id
+ *
+ * @since 3.1.0
+ *
+ * @return int Blog id
+ */
+function get_current_blog_id() {
+        global $blog_id;
+        return absint($blog_id);
+}
+
+/**
</ins><span class="cx">  * Display or retrieve page title for all areas of blog.
</span><span class="cx">  *
</span><span class="cx">  * By default, the page title will display the separator before the page title,
</span></span></pre></div>
<a id="trunkwpincludespostphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post.php (16049 => 16050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post.php        2010-10-28 15:30:39 UTC (rev 16049)
+++ trunk/wp-includes/post.php        2010-10-28 15:46:11 UTC (rev 16050)
</span><span class="lines">@@ -1016,7 +1016,7 @@
</span><span class="cx">  *   behave like edit_posts.
</span><span class="cx">  * - publish_posts - Controls publishing objects of this post type.
</span><span class="cx">  * - read_private_posts - Controls whether private objects can be read.
</span><del>- 
</del><ins>+
</ins><span class="cx">  * These four primitive capabilities are checked in core in various locations.
</span><span class="cx">  * There are also seven other primitive capabilities which are not referenced
</span><span class="cx">  * directly in core, except in map_meta_cap(), which takes the three aforementioned
</span><span class="lines">@@ -2265,11 +2265,11 @@
</span><span class="cx">                 'meta_value' =&gt;'', 'post_type' =&gt; 'post', 'post_status' =&gt; 'draft, publish, future, pending, private',
</span><span class="cx">                 'suppress_filters' =&gt; true
</span><span class="cx">         );
</span><del>-        
</del><ins>+
</ins><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx"> 
</span><span class="cx">         $results = get_posts( $r );
</span><del>-        
</del><ins>+
</ins><span class="cx">         // Backward compatibility. Prior to 3.1 expected posts to be returned in array
</span><span class="cx">         if ( ARRAY_A == $output ){
</span><span class="cx">                 foreach( $results as $key =&gt; $result ) {
</span><span class="lines">@@ -4141,7 +4141,7 @@
</span><span class="cx">  * @return string The date.
</span><span class="cx">  */
</span><span class="cx"> function _get_last_post_time( $timezone, $field ) {
</span><del>-        global $wpdb, $blog_id;
</del><ins>+        global $wpdb;
</ins><span class="cx"> 
</span><span class="cx">         if ( !in_array( $field, array( 'date', 'modified' ) ) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -4152,7 +4152,7 @@
</span><span class="cx"> 
</span><span class="cx">         $post_types = apply_filters( &quot;get_lastpost{$field}_post_types&quot;, (array) $post_types );
</span><span class="cx"> 
</span><del>-        $key = &quot;lastpost{$field}:$blog_id:$timezone:&quot; . md5( serialize( $post_types ) );
</del><ins>+        $key = &quot;lastpost{$field}:&quot; . get_current_blog_id() . &quot;:$timezone:&quot; . md5( serialize( $post_types ) );
</ins><span class="cx"> 
</span><span class="cx">         $date = wp_cache_get( $key, 'timeinfo' );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/user.php (16049 => 16050)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/user.php        2010-10-28 15:30:39 UTC (rev 16049)
+++ trunk/wp-includes/user.php        2010-10-28 15:46:11 UTC (rev 16050)
</span><span class="lines">@@ -376,7 +376,7 @@
</span><span class="cx">                         $this-&gt;query_vars = wp_parse_args( $query, array(
</span><span class="cx">                                 'blog_id' =&gt; $GLOBALS['blog_id'],
</span><span class="cx">                                 'role' =&gt; '',
</span><del>-                                'meta_key' =&gt; '', 
</del><ins>+                                'meta_key' =&gt; '',
</ins><span class="cx">                                 'meta_value' =&gt; '',
</span><span class="cx">                                 'meta_compare' =&gt; '',
</span><span class="cx">                                 'include' =&gt; array(),
</span><span class="lines">@@ -572,10 +572,8 @@
</span><span class="cx">  * @return array List of users that are part of that Blog ID
</span><span class="cx">  */
</span><span class="cx"> function get_users_of_blog( $id = '' ) {
</span><del>-        global $blog_id;
-
</del><span class="cx">         if ( empty( $id ) )
</span><del>-                $id = (int) $blog_id;
</del><ins>+                $id = get_current_blog_id();
</ins><span class="cx"> 
</span><span class="cx">         return get_users( array( 'blog_id' =&gt; $id ) );
</span><span class="cx"> }
</span><span class="lines">@@ -593,7 +591,7 @@
</span><span class="cx">         global $wpdb;
</span><span class="cx"> 
</span><span class="cx">         if ( !is_multisite() ) {
</span><del>-                global $blog_id;
</del><ins>+                $blog_id = get_current_blog_id();
</ins><span class="cx">                 $blogs = array();
</span><span class="cx">                 $blogs[ $blog_id ]-&gt;userblog_id = $blog_id;
</span><span class="cx">                 $blogs[ $blog_id ]-&gt;blogname = get_option('blogname');
</span><span class="lines">@@ -757,10 +755,10 @@
</span><span class="cx">  * @return array Includes a grand total and an array of counts indexed by role strings.
</span><span class="cx">  */
</span><span class="cx"> function count_users($strategy = 'time') {
</span><del>-        global $wpdb, $blog_id, $wp_roles;
</del><ins>+        global $wpdb, $wp_roles;
</ins><span class="cx"> 
</span><span class="cx">         // Initialize
</span><del>-        $id = (int) $blog_id;
</del><ins>+        $id = get_current_blog_id();
</ins><span class="cx">         $blog_prefix = $wpdb-&gt;get_blog_prefix($id);
</span><span class="cx">         $result = array();
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>