get_current_blog_id(). Props aaroncampbell. fixes #15233

git-svn-id: http://svn.automattic.com/wordpress/trunk@16050 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-10-28 15:46:11 +00:00
parent b118cfabbc
commit 23948ab364
5 changed files with 26 additions and 18 deletions

View File

@ -387,7 +387,7 @@ EOD;
* @since 2.2.0
*/
function create_post() {
global $blog_id, $user_ID;
global $user_ID;
$this->get_accepted_content_type($this->atom_content_types);
$parser = new AtomParser();
@ -419,7 +419,7 @@ EOD;
if ( !current_user_can($cap) )
$this->auth_required(__('Sorry, you do not have the right to edit/publish new posts.'));
$blog_ID = (int ) $blog_id;
$blog_ID = get_current_blog_id();
$post_status = ($publish) ? 'publish' : 'draft';
$post_author = (int) $user_ID;
$post_title = $entry->title[1];

View File

@ -7,8 +7,6 @@ class WP_Admin_Bar {
var $user;
function initialize() {
global $blog_id;
/* Only load super admin menu code if the logged in user is a super admin */
if ( is_super_admin() ) {
require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' );
@ -28,7 +26,7 @@ class WP_Admin_Bar {
$this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
$this->user->account_domain = $this->user->domain;
} else {
$this->user->active_blog = $this->user->blogs[$blog_id];
$this->user->active_blog = $this->user->blogs[get_current_blog_id()];
$this->user->domain = trailingslashit( home_url() );
$this->user->account_domain = $this->user->domain;
}

View File

@ -491,6 +491,18 @@ function get_bloginfo( $show = '', $filter = 'raw' ) {
return $output;
}
/**
* 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);
}
/**
* Display or retrieve page title for all areas of blog.
*

View File

@ -4141,7 +4141,7 @@ function get_lastpostmodified($timezone = 'server') {
* @return string The date.
*/
function _get_last_post_time( $timezone, $field ) {
global $wpdb, $blog_id;
global $wpdb;
if ( !in_array( $field, array( 'date', 'modified' ) ) )
return false;
@ -4152,7 +4152,7 @@ function _get_last_post_time( $timezone, $field ) {
$post_types = apply_filters( "get_lastpost{$field}_post_types", (array) $post_types );
$key = "lastpost{$field}:$blog_id:$timezone:" . md5( serialize( $post_types ) );
$key = "lastpost{$field}:" . get_current_blog_id() . ":$timezone:" . md5( serialize( $post_types ) );
$date = wp_cache_get( $key, 'timeinfo' );

View File

@ -572,10 +572,8 @@ function get_users( $args = array() ) {
* @return array List of users that are part of that Blog ID
*/
function get_users_of_blog( $id = '' ) {
global $blog_id;
if ( empty( $id ) )
$id = (int) $blog_id;
$id = get_current_blog_id();
return get_users( array( 'blog_id' => $id ) );
}
@ -593,7 +591,7 @@ function get_blogs_of_user( $id, $all = false ) {
global $wpdb;
if ( !is_multisite() ) {
global $blog_id;
$blog_id = get_current_blog_id();
$blogs = array();
$blogs[ $blog_id ]->userblog_id = $blog_id;
$blogs[ $blog_id ]->blogname = get_option('blogname');
@ -757,10 +755,10 @@ function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {
* @return array Includes a grand total and an array of counts indexed by role strings.
*/
function count_users($strategy = 'time') {
global $wpdb, $blog_id, $wp_roles;
global $wpdb, $wp_roles;
// Initialize
$id = (int) $blog_id;
$id = get_current_blog_id();
$blog_prefix = $wpdb->get_blog_prefix($id);
$result = array();