Reduce use of global. Use get_blog_details() instead. fixes #22090

git-svn-id: http://core.svn.wordpress.org/trunk@22108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-10-04 12:40:09 +00:00
parent 830e30031a
commit 7a86de87fb
6 changed files with 20 additions and 18 deletions

View File

@ -132,9 +132,6 @@ class WP_Importer {
exit();
}
$blog_id = (int) $blog->blog_id;
// Restore global $current_blog
global $current_blog;
$current_blog = $blog;
}
if ( function_exists( 'is_multisite' ) ) {
@ -212,8 +209,6 @@ class WP_Importer {
* @return bool
*/
function is_user_over_quota() {
global $current_blog;
if ( function_exists( 'upload_is_user_over_quota' ) ) {
if ( upload_is_user_over_quota( 1 ) ) {
echo "Sorry, you have used your upload quota.\n";

View File

@ -25,6 +25,8 @@ if ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option( 'delete_blog_hash' )
}
}
$blog = get_blog_details();
$title = __( 'Delete Site' );
$parent_file = 'tools.php';
require_once( './admin-header.php' );
@ -72,7 +74,7 @@ Webmaster
<form method="post" name="deletedirect">
<?php wp_nonce_field( 'delete-blog' ) ?>
<input type="hidden" name="action" value="deleteblog" />
<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $current_blog->domain : $current_blog->domain . $current_blog->path ); ?></strong></label></p>
<p><input id="confirmdelete" type="checkbox" name="confirmdelete" value="1" /> <label for="confirmdelete"><strong><?php printf( __( "I'm sure I want to permanently disable my site, and I am aware I can never get it back or use %s again." ), is_subdomain_install() ? $blog->domain : $blog->domain . $blog->path ); ?></strong></label></p>
<?php submit_button( __( 'Delete My Site Permanently' ) ); ?>
</form>
<?php

View File

@ -3660,7 +3660,8 @@ class wp_xmlrpc_server extends IXR_Server {
* @access protected
*/
function _multisite_getUsersBlogs($args) {
global $current_blog;
$current_blog = get_blog_details();
$domain = $current_blog->domain;
$path = $current_blog->path . 'xmlrpc.php';

View File

@ -3118,13 +3118,13 @@ function wp_suspend_cache_invalidation($suspend = true) {
* @return bool True if not multisite or $blog_id is main site
*/
function is_main_site( $blog_id = '' ) {
global $current_site, $current_blog;
global $current_site;
if ( !is_multisite() )
if ( ! is_multisite() )
return true;
if ( !$blog_id )
$blog_id = $current_blog->blog_id;
if ( ! $blog_id )
$blog_id = get_current_blog_id();
return $blog_id == $current_site->blog_id;
}

View File

@ -118,11 +118,11 @@ function get_id_from_blogname( $slug ) {
*
* @since MU
*
* @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against.
* @param int|string|array $fields A blog ID, a blog slug, or an array of fields to query against. Optional. If not specified the current blog ID is used.
* @param bool $get_all Whether to retrieve all details or only the details in the blogs table. Default is true.
* @return object Blog details.
*/
function get_blog_details( $fields, $get_all = true ) {
function get_blog_details( $fields = null, $get_all = true ) {
global $wpdb;
if ( is_array($fields ) ) {
@ -166,7 +166,9 @@ function get_blog_details( $fields, $get_all = true ) {
return false;
}
} else {
if ( !is_numeric( $fields ) )
if ( ! $fields )
$blog_id = get_current_blog_id();
elseif ( ! is_numeric( $fields ) )
$blog_id = get_id_from_blogname( $fields );
else
$blog_id = $fields;

View File

@ -69,7 +69,9 @@ function wp_get_active_network_plugins() {
* @return bool|string Returns true on success, or drop-in file to include.
*/
function ms_site_check() {
global $wpdb, $current_blog;
global $wpdb;
$blog = get_blog_details();
// Allow short-circuiting
$check = apply_filters('ms_site_check', null);
@ -80,21 +82,21 @@ function ms_site_check() {
if ( is_super_admin() )
return true;
if ( '1' == $current_blog->deleted ) {
if ( '1' == $blog->deleted ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
return WP_CONTENT_DIR . '/blog-deleted.php';
else
wp_die( __( 'This user has elected to delete their account and the content is no longer available.' ), '', array( 'response' => 410 ) );
}
if ( '2' == $current_blog->deleted ) {
if ( '2' == $blog->deleted ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-inactive.php' ) )
return WP_CONTENT_DIR . '/blog-inactive.php';
else
wp_die( sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact <a href="mailto:%1$s">%1$s</a>.' ), str_replace( '@', ' AT ', get_site_option( 'admin_email', "support@{$current_site->domain}" ) ) ) );
}
if ( $current_blog->archived == '1' || $current_blog->spam == '1' ) {
if ( $blog->archived == '1' || $blog->spam == '1' ) {
if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
return WP_CONTENT_DIR . '/blog-suspended.php';
else