Skip to:
Content

BuddyPress.org

Changeset 4107


Ignore:
Timestamp:
03/11/2011 06:02:47 PM (14 years ago)
Author:
boonebgorges
Message:

Audit of the use of ->blog_id to change to ->blogid where possible, to better account for switch_to_blog() use. Fixes #2984. Props wpmuguru

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-blogs/bp-blogs-functions.php

    r3940 r4107  
    265265
    266266function bp_blogs_add_user_to_blog( $user_id, $role = false, $blog_id = 0 ) {
    267     global $wpdb, $current_blog;
    268 
    269     if ( empty( $blog_id ) && isset( $current_blog ) )
    270         $blog_id = $current_blog->blog_id;
     267    global $wpdb;
     268
     269    if ( empty( $blog_id ) && isset( $wpdb->blogid ) )
     270        $blog_id = $wpdb->blogid;
    271271    else
    272272        $blog_id = BP_ROOT_BLOG;
     
    291291
    292292function bp_blogs_remove_user_from_blog( $user_id, $blog_id = 0 ) {
    293     global $current_blog;
     293    global $wpdb;
    294294
    295295    if ( empty( $blog_id ) )
    296         $blog_id = $current_blog->blog_id;
     296        $blog_id = $wpdb->blogid;
    297297
    298298    bp_blogs_remove_blog_for_user( $user_id, $blog_id );
     
    330330
    331331function bp_blogs_remove_post( $post_id, $blog_id = 0, $user_id = 0 ) {
    332     global $current_blog, $bp;
    333 
    334     if ( empty( $current_blog->blog_id ) )
     332    global $wpdb, $bp;
     333
     334    if ( empty( $wpdb->blogid ) )
    335335        return false;
    336336
     
    338338
    339339    if ( !$blog_id )
    340         $blog_id = (int)$current_blog->blog_id;
     340        $blog_id = (int)$wpdb->blogid;
    341341
    342342    if ( !$user_id )
  • trunk/bp-blogs/bp-blogs-widgets.php

    r3300 r4107  
    77
    88function bp_blogs_register_widgets() {
    9     global $current_blog, $bp;
     9    global $wpdb, $bp;
    1010
    11     if ( bp_is_active( 'activity' ) && (int)$current_blog->blog_id == BP_ROOT_BLOG )
     11    if ( bp_is_active( 'activity' ) && (int)$wpdb->blogid == BP_ROOT_BLOG )
    1212        add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");') );
    1313}
  • trunk/bp-core/admin/bp-core-admin.php

    r4105 r4107  
    1919 */
    2020function bp_core_activation_notice() {
    21     global $wp_rewrite, $current_blog, $bp;
     21    global $wp_rewrite, $wpdb, $bp;
    2222
    2323    if ( isset( $_POST['permalink_structure'] ) )
     
    2727        return false;
    2828
    29     if ( !empty( $current_blog ) ) {
    30         if ( $current_blog->blog_id != BP_ROOT_BLOG ) {
     29    if ( !empty( $wpdb->blogid ) ) {
     30        if ( $wpdb->blogid != BP_ROOT_BLOG ) {
    3131            return false;
    3232        }
     
    9191 */
    9292function bp_core_admin_settings() {
    93     global $wpdb, $bp, $current_blog;
     93    global $wpdb, $bp;
    9494
    9595    $ud = get_userdata( $bp->loggedin_user->id );
  • trunk/bp-core/admin/bp-core-update.php

    r4106 r4107  
    740740
    741741    function step_ms_update_save() {
    742         global $current_blog;
     742        global $wpdb;
    743743
    744744        if ( isset( $_POST['submit'] ) ) {
     
    762762            } else {
    763763                // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on
    764                 if ( $current_blog->blog_id != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
     764                if ( $wpdb->blogid != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
    765765                    switch_to_blog( BP_ROOT_BLOG );
    766766
     
    771771                update_option( 'bp-pages', $bp_pages );
    772772
    773                 if ( $current_blog->blog_id != BP_ROOT_BLOG )
     773                if ( $wpdb->blogid != BP_ROOT_BLOG )
    774774                    restore_current_blog();
    775775
     
    810810
    811811    function step_pages_save() {
    812         global $current_blog;
     812        global $wpdb;
    813813
    814814        if ( isset( $_POST['submit'] ) && isset( $_POST['bp_pages'] ) ) {
     
    816816
    817817            // Make sure that the pages are created on the BP_ROOT_BLOG, no matter which Dashboard the setup is being run on
    818             if ( !empty( $current_blog->blog_id ) && $current_blog->blog_id != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
     818            if ( !empty( $wpdb->blogid ) && $wpdb->blogid != BP_ROOT_BLOG && !defined( 'BP_ENABLE_MULTIBLOG' ) )
    819819                switch_to_blog( BP_ROOT_BLOG );
    820820
     
    829829            update_option( 'bp-pages', $bp_pages );
    830830
    831             if ( !empty( $current_blog->blog_id ) && $current_blog->blog_id != BP_ROOT_BLOG )
     831            if ( !empty( $wpdb->blogid ) && $wpdb->blogid != BP_ROOT_BLOG )
    832832                restore_current_blog();
    833833
     
    853853                    $permalink_structure = preg_replace( '#/+#', '/', '/' . $_POST['permalink_structure'] );
    854854
    855                 if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain.$current_site->path == $current_blog->domain.$current_blog->path )
     855                if ( ( defined( 'VHOST' ) && constant( 'VHOST' ) == 'no' ) && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path )
    856856                    $permalink_structure = '/blog' . $permalink_structure;
    857857
  • trunk/bp-core/bp-core-avatars.php

    r3982 r4107  
    564564 * Returns the absolute upload path for the WP installation
    565565 *
    566  * @global object $current_blog Current blog information
     566 * @global object $wpdb WordPress database global
    567567 * @uses wp_upload_dir To get upload directory info
    568568 * @return string Absolute path to WP upload directory
    569569 */
    570570function bp_core_avatar_upload_path() {
    571     global $current_blog;
     571    global $wpdb;
    572572
    573573    // Get upload directory information from current site
     
    579579
    580580        // If multisite, and current blog does not match root blog, make adjustments
    581         if ( is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id )
     581        if ( is_multisite() && BP_ROOT_BLOG != $wpdb->blogid )
    582582            $basedir = get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    583583    } else {
     
    593593 * Returns the raw base URL for root site upload location
    594594 *
    595  * @global object $current_blog Current blog information
     595 * @global object $wpdb WordPress database global
    596596 * @uses wp_upload_dir To get upload directory info
    597597 * @return string Full URL to current upload location
    598598 */
    599599function bp_core_avatar_url() {
    600     global $current_blog;
     600    global $wpdb;
    601601
    602602    // Get upload directory information from current site
     
    608608
    609609        // If multisite, and current blog does not match root blog, make adjustments
    610         if ( is_multisite() && BP_ROOT_BLOG != $current_blog->blog_id )
     610        if ( is_multisite() && BP_ROOT_BLOG != $wpdb->blogid )
    611611            $baseurl = trailingslashit( get_blog_option( BP_ROOT_BLOG, 'home' ) ) . get_blog_option( BP_ROOT_BLOG, 'upload_path' );
    612612    } else {
  • trunk/bp-core/bp-core-catchuri.php

    r4104 r4107  
    2828function bp_core_set_uri_globals() {
    2929    global $bp, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    30     global $current_blog;
     30    global $current_blog, $wpdb;
    3131
    3232    // Create global component, action, and item variables
     
    3737    // on multiple blogs
    3838    if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) {
    39         if ( BP_ROOT_BLOG != (int) $current_blog->blog_id )
     39        if ( BP_ROOT_BLOG != (int) $wpdb->blogid )
    4040            return false;
    4141    }
  • trunk/bp-core/bp-core-cssjs.php

    r4027 r4107  
    3333
    3434function bp_core_confirmation_js() {
    35     global $current_blog;
     35    global $wpdb;
    3636
    37     if ( is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
     37    if ( is_multisite() && $wpdb->blogid != BP_ROOT_BLOG )
    3838        return false;
    3939
  • trunk/bp-core/bp-core-filters.php

    r4041 r4107  
    6868 */
    6969function bp_core_allow_default_theme( $themes ) {
    70     global $bp, $current_blog;
     70    global $bp, $wpdb;
    7171
    7272    if ( !is_super_admin() )
    7373        return $themes;
    7474
    75     if ( $current_blog->blog_id == BP_ROOT_BLOG ) {
     75    if ( $wpdb->blogid == BP_ROOT_BLOG ) {
    7676        $themes['bp-default'] = 1;
    7777    }
    78 
     78   
    7979    return $themes;
    8080}
     
    126126 */
    127127function bp_core_login_redirect( $redirect_to ) {
    128     global $bp, $current_blog;
    129 
    130     if ( is_multisite() && $current_blog->blog_id != BP_ROOT_BLOG )
     128    global $bp, $wpdb;
     129
     130    if ( is_multisite() && $wpdb->blogid != BP_ROOT_BLOG )
    131131        return $redirect_to;
    132132
  • trunk/bp-core/bp-core-functions.php

    r4088 r4107  
    169169 */
    170170function bp_core_get_root_domain() {
    171     global $current_blog;
     171    global $wpdb;
    172172
    173173    if ( defined( 'BP_ENABLE_MULTIBLOG' ) )
    174         $domain = get_home_url( $current_blog->blog_id );
     174        $domain = get_home_url( $wpdb->blogid );
    175175    else
    176176        $domain = get_home_url( BP_ROOT_BLOG );
  • trunk/bp-core/bp-core-template.php

    r4076 r4107  
    219219
    220220function bp_get_page_title() {
    221     global $bp, $post, $wp_query, $current_blog;
     221    global $bp, $post, $wp_query;
    222222
    223223    // Home
  • trunk/bp-members/bp-members-buddybar.php

    r3955 r4107  
    4242// **** "Blog Authors" Menu (visible when not logged in) ********
    4343function bp_adminbar_authors_menu() {
    44     global $bp, $current_blog, $wpdb;
     44    global $bp, $wpdb;
    4545
    4646    // Only for multisite
     
    4949
    5050    // Hide on root blog
    51     if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
    52         return false;
    53 
    54     $blog_prefix = $wpdb->get_blog_prefix( $current_blog->blog_id );
     51    if ( $wpdb->blogid == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
     52        return false;
     53
     54    $blog_prefix = $wpdb->get_blog_prefix( $wpdb->blogid );
    5555    $authors     = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
    5656
  • trunk/bp-members/bp-members-template.php

    r4093 r4107  
    604604
    605605/**
    606  * bp_get_nav()
    607  * TEMPLATE TAG
    608  *
    609606 * Uses the $bp->bp_nav global to render out the navigation within a BuddyPress install.
    610607 * Each component adds to this navigation array within its own [component_name]_setup_nav() function.
     
    622619 */
    623620function bp_get_loggedin_user_nav() {
    624     global $bp, $current_blog;
     621    global $bp;
    625622
    626623    // Loop through each navigation item
Note: See TracChangeset for help on using the changeset viewer.