Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/22/2010 12:28:41 PM (15 years ago)
Author:
apeatling
Message:

Make sure that we have a valid $post object on all BP pages.

File:
1 edited

Legend:

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

    r2863 r2865  
    147147
    148148            /* Remove everything from the URI up to the offset and take it from there. */
    149             for ( $i = 0; $i < $uri_offset; $i++ ) {
     149            for ( $i = 0; $i < $uri_offset; $i++ )
    150150                unset( $bp_uri[$i] );
    151             }
    152151
    153152            $current_component = $bp_uri[$uri_offset];
     
    209208 */
    210209function bp_core_load_template( $templates ) {
    211     global $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    212 
    213     /* Determine if the root object WP page exists for this request (is there an API function for this?)*/
     210    global $post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
     211
     212    /* Determine if the root object WP page exists for this request (TODO: is there an API function for this?) */
    214213    if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) )
    215214        return false;
     
    221220    }
    222221
    223     $wp_query->queried_object = &get_post( $object_id );
    224     $wp_query->queried_object_id = $object_id;
     222    /* Make the queried/post object an actual valid page */
     223    if ( !empty( $object_id ) ) {
     224        $wp_query->queried_object = &get_post( $object_id );
     225        $wp_query->queried_object_id = $object_id;
     226
     227        $post = $wp_query->queried_object;
     228    }
    225229
    226230    /* Fetch each template and add the php suffix */
Note: See TracChangeset for help on using the changeset viewer.