Skip to:
Content

BuddyPress.org

Changeset 5760


Ignore:
Timestamp:
02/13/2012 07:28:31 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Use get_page_by_path() in bp_core_load_template() to properly check if page exists at uri offset. Fix #4000.

File:
1 edited

Legend:

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

    r5729 r5760  
    343343 */
    344344function bp_core_load_template( $templates ) {
    345     global $post, $bp, $wpdb, $wp_query;
    346 
    347     // Bail if there is no offset
    348     if ( empty( $bp->unfiltered_uri[$bp->unfiltered_uri_offset] ) )
    349         return false;
    350 
    351     // Determine if the root object WP page exists for this request
    352     // (@todo: use reliable API function (get_page_by_path() doesn't work?)
    353     if ( !$wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp->unfiltered_uri[$bp->unfiltered_uri_offset] ) ) )
    354         return false;
     345    global $post, $bp, $wp_query;
     346
     347    // Bail if there is a uri offset but not a page in its place.
     348    // * Possibly root profiles are enabled
     349    if ( !empty( $bp->unfiltered_uri_offset ) ) {       
     350        if ( ! get_page_by_path( $bp->unfiltered_uri[$bp->unfiltered_uri_offset] ) ) {
     351            return false;
     352        }
     353    }
    355354
    356355    // Set the root object as the current wp_query-ied item
Note: See TracChangeset for help on using the changeset viewer.