Skip to:
Content

BuddyPress.org

Changeset 4630


Ignore:
Timestamp:
07/09/2011 07:14:50 PM (13 years ago)
Author:
boonebgorges
Message:

Introduces bp_is_multiblog_mode() to reduce BP_ENABLE_MULTIBLOG checks throughout. See #3314

Location:
trunk/bp-core
Files:
2 edited

Legend:

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

    r4628 r4630  
    3434    $bp->action_variables = $bp->displayed_user->id = '';
    3535
    36     // Only catch URI's on the root blog if we are not running
    37     // on multiple blogs
    38     if ( !defined( 'BP_ENABLE_MULTIBLOG' ) && is_multisite() ) {
    39         if ( bp_get_root_blog_id() != (int) $wpdb->blogid )
    40             return false;
     36    // Don't catch URIs on non-root blogs unless multiblog mode is on
     37    if ( !bp_is_root_blog() && !bp_is_multiblog_mode() ) {
     38        return false;
    4139    }
    4240
     
    6765
    6866    // Running off blog other than root
    69     if ( is_multisite() && !is_subdomain_install() && ( defined( 'BP_ENABLE_MULTIBLOG' ) || 1 != bp_get_root_blog_id() ) ) {
     67    if ( is_multisite() && !is_subdomain_install() && ( bp_is_multiblog_mode() || 1 != bp_get_root_blog_id() ) ) {
    7068
    7169        // Any subdirectory names must be removed from $bp_uri.
  • trunk/bp-core/bp-core-functions.php

    r4628 r4630  
    8181 
    8282    // Upgrading from an earlier version of BP pre-1.3
    83     if ( !isset( $page_ids['members'] ) && $ms_page_ids = get_site_option( 'bp-pages' ) ) {
    84         $is_enable_multiblog = is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG ? true : false;
    85  
    86         $page_blog_id = $is_enable_multiblog ? get_current_blog_id() : bp_get_root_blog_id();
     83    if ( !isset( $page_ids['members'] ) && $ms_page_ids = get_site_option( 'bp-pages' ) ) { 
     84        $page_blog_id = bp_is_multiblog_mode() ? get_current_blog_id() : bp_get_root_blog_id();
    8785
    8886        if ( isset( $ms_page_ids[$page_blog_id] ) ) {
     
    128126    if ( $page_ids = bp_core_get_page_meta() ) {
    129127
    130         $posts_table_name = is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ? $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts' : $wpdb->posts;
     128        $posts_table_name = bp_is_multiblog_mode() ? $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'posts' : $wpdb->posts;
    131129        $page_ids_sql     = implode( ',', (array)$page_ids );
    132130        $page_names       = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent, post_title FROM {$posts_table_name} WHERE ID IN ({$page_ids_sql}) AND post_status = 'publish' " ) );
     
    191189    $do_network_admin = false;
    192190
    193     if ( is_multisite() && ( !defined( 'BP_ENABLE_MULTIBLOG' ) || !BP_ENABLE_MULTIBLOG ) )
     191    if ( is_multisite() && !bp_is_multiblog_mode() )
    194192        $do_network_admin = true;
    195193
     
    10911089
    10921090        // Root blog is the main site on this network
    1093         if ( is_multisite() && !defined( 'BP_ENABLE_MULTIBLOG' ) ) {
     1091        if ( is_multisite() && !bp_is_multiblog_mode() ) {
    10941092            $current_site = get_current_site();
    10951093            $root_blog_id = $current_site->blog_id;
    10961094
    1097         // Root blog is every site on this network
    1098         } elseif ( is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) ) {
     1095        // Root blog is whatever the current site is (could be any site on the network)
     1096        } elseif ( is_multisite() && bp_is_multiblog_mode() ) {
    10991097            $root_blog_id = get_current_blog_id();
    11001098
     
    12131211}
    12141212
     1213/**
     1214 * Are we running multiblog mode?
     1215 *
     1216 * Note that BP_ENABLE_MULTIBLOG is different from (but dependent on) WP Multisite. "Multiblog" is
     1217 * a BP setup that allows BP content to be viewed in the theme, and with the URL, of every blog
     1218 * on the network. Thus, instead of having all 'boonebgorges' links go to
     1219 *   http://example.com/members/boonebgorges
     1220 * on the root blog, each blog will have its own version of the same profile content, eg
     1221 *   http://site2.example.com/members/boonebgorges (for subdomains)
     1222 *   http://example.com/site2/members/boonebgorges (for subdirectories)
     1223 *
     1224 * Multiblog mode is disabled by default, meaning that all BP content must be viewed on the root
     1225 * blog.
     1226 *
     1227 * @package BuddyPress
     1228 * @since 1.3
     1229 *
     1230 * @uses apply_filters() Filter 'bp_is_multiblog_mode' to alter
     1231 * @return bool False when multiblog mode is disabled (default); true when enabled
     1232 */
     1233function bp_is_multiblog_mode() {
     1234    return apply_filters( 'bp_is_multiblog_mode', is_multisite() && defined( 'BP_ENABLE_MULTIBLOG' ) && BP_ENABLE_MULTIBLOG );
     1235}
     1236
    12151237/** Global Manipulators *******************************************************/
    12161238
Note: See TracChangeset for help on using the changeset viewer.