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

View File

@ -7,8 +7,6 @@ class WP_Admin_Bar {
var $user; var $user;
function initialize() { function initialize() {
global $blog_id;
/* Only load super admin menu code if the logged in user is a super admin */ /* Only load super admin menu code if the logged in user is a super admin */
if ( is_super_admin() ) { if ( is_super_admin() ) {
require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' ); 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->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; $this->user->account_domain = $this->user->domain;
} else { } 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->domain = trailingslashit( home_url() );
$this->user->account_domain = $this->user->domain; $this->user->account_domain = $this->user->domain;
} }
@ -85,7 +83,7 @@ class WP_Admin_Bar {
function remove_menu( $id ) { function remove_menu( $id ) {
return $this->remove_node( $id, $this->menu ); return $this->remove_node( $id, $this->menu );
} }
function render() { function render() {
?> ?>
<div id="wpadminbar" class="snap_nopreview no-grav"> <div id="wpadminbar" class="snap_nopreview no-grav">

View File

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

View File

@ -1016,7 +1016,7 @@ function register_post_type($post_type, $args = array()) {
* behave like edit_posts. * behave like edit_posts.
* - publish_posts - Controls publishing objects of this post type. * - publish_posts - Controls publishing objects of this post type.
* - read_private_posts - Controls whether private objects can be read. * - read_private_posts - Controls whether private objects can be read.
* These four primitive capabilities are checked in core in various locations. * These four primitive capabilities are checked in core in various locations.
* There are also seven other primitive capabilities which are not referenced * There are also seven other primitive capabilities which are not referenced
* directly in core, except in map_meta_cap(), which takes the three aforementioned * directly in core, except in map_meta_cap(), which takes the three aforementioned
@ -2265,11 +2265,11 @@ function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private', 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'draft, publish, future, pending, private',
'suppress_filters' => true 'suppress_filters' => true
); );
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
$results = get_posts( $r ); $results = get_posts( $r );
// Backward compatibility. Prior to 3.1 expected posts to be returned in array // Backward compatibility. Prior to 3.1 expected posts to be returned in array
if ( ARRAY_A == $output ){ if ( ARRAY_A == $output ){
foreach( $results as $key => $result ) { foreach( $results as $key => $result ) {
@ -4141,7 +4141,7 @@ function get_lastpostmodified($timezone = 'server') {
* @return string The date. * @return string The date.
*/ */
function _get_last_post_time( $timezone, $field ) { function _get_last_post_time( $timezone, $field ) {
global $wpdb, $blog_id; global $wpdb;
if ( !in_array( $field, array( 'date', 'modified' ) ) ) if ( !in_array( $field, array( 'date', 'modified' ) ) )
return false; 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 ); $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' ); $date = wp_cache_get( $key, 'timeinfo' );

View File

@ -376,7 +376,7 @@ class WP_User_Query extends WP_Object_Query {
$this->query_vars = wp_parse_args( $query, array( $this->query_vars = wp_parse_args( $query, array(
'blog_id' => $GLOBALS['blog_id'], 'blog_id' => $GLOBALS['blog_id'],
'role' => '', 'role' => '',
'meta_key' => '', 'meta_key' => '',
'meta_value' => '', 'meta_value' => '',
'meta_compare' => '', 'meta_compare' => '',
'include' => array(), 'include' => array(),
@ -572,10 +572,8 @@ function get_users( $args = array() ) {
* @return array List of users that are part of that Blog ID * @return array List of users that are part of that Blog ID
*/ */
function get_users_of_blog( $id = '' ) { function get_users_of_blog( $id = '' ) {
global $blog_id;
if ( empty( $id ) ) if ( empty( $id ) )
$id = (int) $blog_id; $id = get_current_blog_id();
return get_users( array( 'blog_id' => $id ) ); return get_users( array( 'blog_id' => $id ) );
} }
@ -593,7 +591,7 @@ function get_blogs_of_user( $id, $all = false ) {
global $wpdb; global $wpdb;
if ( !is_multisite() ) { if ( !is_multisite() ) {
global $blog_id; $blog_id = get_current_blog_id();
$blogs = array(); $blogs = array();
$blogs[ $blog_id ]->userblog_id = $blog_id; $blogs[ $blog_id ]->userblog_id = $blog_id;
$blogs[ $blog_id ]->blogname = get_option('blogname'); $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. * @return array Includes a grand total and an array of counts indexed by role strings.
*/ */
function count_users($strategy = 'time') { function count_users($strategy = 'time') {
global $wpdb, $blog_id, $wp_roles; global $wpdb, $wp_roles;
// Initialize // Initialize
$id = (int) $blog_id; $id = get_current_blog_id();
$blog_prefix = $wpdb->get_blog_prefix($id); $blog_prefix = $wpdb->get_blog_prefix($id);
$result = array(); $result = array();