Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/25/2010 06:01:57 PM (14 years ago)
Author:
djpaul
Message:

Don't send 404 headers on good pages; reverts parts of r3488. Fixes #2969

File:
1 edited

Legend:

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

    r3539 r3583  
    106106    // Reset the keys by merging with an empty array
    107107    $bp_uri            = array_merge( array(), $bp_uri );
    108     $bp_unfiltered_uri = $bp_uri;
    109108
    110109    // If a component is set to the front page, force its name into $bp_uri so that $current_component is populated
     
    114113            $bp_uri[0] = $post->post_name;
    115114    }
     115
     116    $bp_unfiltered_uri = $bp_uri;
    116117
    117118    // Find a match within registered BuddyPress controlled WP pages (check members first)
     
    229230 */
    230231function bp_core_load_template( $templates ) {
    231     global $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
     232    global $post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
    232233
    233234    // Determine if the root object WP page exists for this request (TODO: is there an API function for this?
    234     if ( !empty( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) )
    235         if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) )
    236             return false;
     235    if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) )
     236        return false;
     237
     238    // Set the root object as the current wp_query-ied item
     239    $object_id = 0;
     240    foreach ( (array)$bp->pages as $page ) {
     241        if ( isset( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) && $page->name == $bp_unfiltered_uri[$bp_unfiltered_uri_offset] )
     242            $object_id = $page->id;
     243    }
     244
     245    // Make the queried/post object an actual valid page
     246    if ( !empty( $object_id ) ) {
     247        $wp_query->queried_object = &get_post( $object_id );
     248        $wp_query->queried_object_id = $object_id;
     249
     250        $post = $wp_query->queried_object;
     251    }
    237252
    238253    // Fetch each template and add the php suffix
     
    241256
    242257    // Filter the template locations so that plugins can alter where they are located
    243     if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) )
     258    if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) {
     259        // Template was located, lets set this as a valid page and not a 404.
     260        status_header( 200 );
     261        $wp_query->is_page = true;
     262        $wp_query->is_404 = false;
     263
    244264        load_template( apply_filters( 'bp_load_template', $located_template ) );
     265    }
    245266
    246267    // Kill any other output after this.
Note: See TracChangeset for help on using the changeset viewer.