Skip to:
Content

BuddyPress.org

Changeset 4110


Ignore:
Timestamp:
03/11/2011 07:48:15 PM (14 years ago)
Author:
boonebgorges
Message:

Fixes BP_ENABLE_ROOT_PROFILES for ->pages. Fixes #2790

File:
1 edited

Legend:

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

    r4107 r4110  
    179179        }
    180180    }
     181   
     182    // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above
     183    if ( empty( $matches ) && defined( 'BP_ENABLE_ROOT_PROFILES' ) && BP_ENABLE_ROOT_PROFILES ) {
     184       
     185        // Make sure there's a user corresponding to $bp_uri[0]
     186        if ( !empty( $bp_uri[0] ) && $root_profile = get_userdatabylogin( $bp_uri[0] ) ) {
     187           
     188            // Force BP to recognize that this is a members page
     189            $matches[]  = 1;
     190            $match      = $bp->pages->members;
     191            $match->key = 'members';
     192           
     193            // Without the 'members' URL chunk, WordPress won't know which page to load
     194            // This filter intercepts the WP query and tells it to load the members page
     195            add_filter( 'request', create_function( '$query_args', '$query_args["pagename"] = "' . $match->name . '"; return $query_args;' ) );
     196       
     197        }
     198   
     199    }
    181200
    182201    // Search doesn't have an associated page, so we check for it separately
     
    188207        return false;
    189208
    190     // Find the offset
     209    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works
    191210    $slug       = !empty ( $match ) ? explode( '/', $match->slug ) : '';
    192     $uri_offset = 0;
     211    $uri_offset = empty( $root_profile ) ? 0 : -1;
    193212
    194213    // Rejig the offset
     
    198217    }
    199218
    200     // Global the unfiltered offset to use in bp_core_load_template()
    201     $bp_unfiltered_uri_offset = $uri_offset;
     219    // Global the unfiltered offset to use in bp_core_load_template().
     220    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0
     221    $bp_unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    202222
    203223    // We have an exact match
     
    212232            // Viewing a specific user
    213233            if ( !empty( $bp_uri[$uri_offset + 1] ) ) {
    214 
     234               
    215235                // Switch the displayed_user based on cmpatbility mode
    216236                if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
Note: See TracChangeset for help on using the changeset viewer.