Skip to:
Content

BuddyPress.org

Changeset 5716


Ignore:
Timestamp:
02/11/2012 06:01:03 AM (10 years ago)
Author:
johnjamesjacoby
Message:

Add root_blog_id variable to $bp global, and remove extra logic from bp_get_root_blog_id().

Location:
trunk
Files:
2 edited

Legend:

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

    r5683 r5716  
    528528 */
    529529function bp_core_get_last_activity( $last_activity_date, $string ) {
    530     if ( !$last_activity_date || empty( $last_activity_date ) )
    531         $last_active = __( 'not recently active', 'buddypress' );
     530
     531    if ( empty( $last_activity_date ) )
     532        $last_active = __( 'Not recently active', 'buddypress' );
    532533    else
    533534        $last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
     
    807808        $is_root_blog = true;
    808809
    809     return apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
     810    return (bool) apply_filters( 'bp_is_root_blog', (bool) $is_root_blog );
    810811}
    811812
     
    814815 *
    815816 * @package BuddyPress
    816  * @since 1.5
    817  *
    818  * @return bool $is_root_blog Returns true if this is bp_get_root_blog_id().
     817 * @since BuddyPress (1.5)
     818 *
     819 * @return int Return the root site ID
    819820 */
    820821function bp_get_root_blog_id() {
    821 
    822     // Default to 1
    823     $root_blog_id = 1;
    824 
    825     // Define on which blog ID BuddyPress should run
    826     if ( !defined( 'BP_ROOT_BLOG' ) ) {
    827 
    828         // Root blog is the main site on this network
    829         if ( is_multisite() && !bp_is_multiblog_mode() ) {
    830             $current_site = get_current_site();
    831             $root_blog_id = $current_site->blog_id;
    832 
    833         // Root blog is whatever the current site is (could be any site on the network)
    834         } elseif ( is_multisite() && bp_is_multiblog_mode() ) {
    835             $root_blog_id = get_current_blog_id();
    836         }
    837 
    838         define( 'BP_ROOT_BLOG', $root_blog_id );
    839 
    840     // Root blog is defined
    841     } else {
    842         $root_blog_id = BP_ROOT_BLOG;
    843     }
    844 
    845     return apply_filters( 'bp_get_root_blog_id', (int) $root_blog_id );
     822    global $bp;
     823
     824    return (int) apply_filters( 'bp_get_root_blog_id', (int) $bp->root_blog_id );
    846825}
    847826
  • trunk/bp-loader.php

    r5675 r5716  
    7575    public $load_deprecated = true;
    7676
     77    /** Root ******************************************************************/
     78
     79    /**
     80     * @var int The root blog ID
     81     */
     82    public $root_blog_id = 1;
     83
    7784    /** Paths *****************************************************************/
    7885
     
    368375     */
    369376    private function setup_globals() {
     377
     378        /** Root **************************************************************/
     379
     380        // BuddyPress Root blog ID
     381        $this->root_blog_id = (int) apply_filters( 'bp_get_root_blog_id', BP_ROOT_BLOG );
    370382
    371383        /** Paths *************************************************************/
     
    429441        // Get the possible DB versions
    430442        $versions               = array();
    431         $versions['1.2']        = get_site_option( 'bp-core-db-version' );
    432         $versions['1.5-multi']  = get_site_option( 'bp-db-version'      );
    433         $versions['1.5-single'] = get_option     ( 'bp-db-version'      );
    434         $versions['1.6-multi']  = get_site_option( '_bp_db_version'     );
    435         $versions['1.6-single'] = get_option     ( '_bp_db_version'    );
     443        $versions['1.2']        = get_site_option(                      'bp-core-db-version' );
     444        $versions['1.5-multi']  = get_site_option(                           'bp-db-version' );
     445        $versions['1.6-multi']  = get_site_option(                          '_bp_db_version' );
     446        $versions['1.5-single'] = get_blog_option( $this->root_blog_id,     'bp-db-version'  );
     447        $versions['1.6-single'] = get_blog_option( $this->root_blog_id,     '_bp_db_version' );
    436448
    437449        // Remove empty array items
    438450        $versions = array_filter( $versions );
    439451
    440         // Get the largest version
    441         $this->db_version_raw = !empty( $versions ) ? (int) max( $versions ) : 0;
     452        // If no 1.6-single exists, use the max of the others
     453        if ( empty( $versions['1.6-single'] ) )
     454            $this->db_version_raw = !empty( $versions ) ? (int) max( $versions ) : 0;
     455
     456        // 1.6-single exists, so trust it
     457        else
     458            $this->db_version_raw = $versions['1.6-single'];
    442459
    443460        // Is this an upgrade to WordPress Network Mode?
Note: See TracChangeset for help on using the changeset viewer.