diff --git bp-core/bp-core-catchuri.php bp-core/bp-core-catchuri.php
index eaaa287..5e27471 100644
|
|
|
function bp_core_enable_root_profiles() { |
| 340 | 340 | * @return bool|null Returns false on failure. |
| 341 | 341 | */ |
| 342 | 342 | function bp_core_load_template( $templates ) { |
| 343 | | global $post, $bp, $wp_query, $wpdb; |
| | 343 | global $wp_query; |
| 344 | 344 | |
| 345 | | // Determine if the root object WP page exists for this request |
| 346 | | // note: get_page_by_path() breaks non-root pages |
| 347 | | if ( !empty( $bp->unfiltered_uri_offset ) ) { |
| 348 | | if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp->unfiltered_uri[$bp->unfiltered_uri_offset] ) ) ) { |
| 349 | | return false; |
| 350 | | } |
| 351 | | } |
| 352 | | |
| 353 | | // Set the root object as the current wp_query-ied item |
| 354 | | $object_id = 0; |
| 355 | | foreach ( (array) $bp->pages as $page ) { |
| 356 | | if ( $page->name == $bp->unfiltered_uri[$bp->unfiltered_uri_offset] ) { |
| 357 | | $object_id = $page->id; |
| 358 | | } |
| 359 | | } |
| | 345 | // add a dummy post |
| | 346 | bp_theme_compat_reset_post( array( |
| | 347 | 'ID' => 0, |
| | 348 | 'is_404' => true, |
| | 349 | 'post_status' => 'publish', |
| | 350 | ) ); |
| 360 | 351 | |
| 361 | | // Make the queried/post object an actual valid page |
| 362 | | if ( !empty( $object_id ) ) { |
| 363 | | $wp_query->queried_object = get_post( $object_id ); |
| 364 | | $wp_query->queried_object_id = $object_id; |
| 365 | | $post = $wp_query->queried_object; |
| 366 | | } |
| | 352 | // need to set theme compat to false since the reset post function |
| | 353 | // automatically sets theme compat to true |
| | 354 | bp_set_theme_compat_active( false ); |
| 367 | 355 | |
| 368 | 356 | // Fetch each template and add the php suffix |
| 369 | 357 | $filtered_templates = array(); |
| … |
… |
function bp_core_load_template( $templates ) { |
| 371 | 359 | $filtered_templates[] = $template . '.php'; |
| 372 | 360 | } |
| 373 | 361 | |
| 374 | | // Filter the template locations so that plugins can alter where they are located |
| 375 | | $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ); |
| 376 | | if ( !empty( $located_template ) ) { |
| | 362 | // bp-default template lookup. will always exist! |
| | 363 | if ( ! bp_use_theme_compat_with_current_theme() ) { |
| | 364 | $template = locate_template( (array) $filtered_templates, false ); |
| | 365 | |
| | 366 | // theme compat doesn't require older bp-default so avoid unnecessary |
| | 367 | // locate_template() call |
| | 368 | } else { |
| | 369 | $template = ''; |
| | 370 | } |
| | 371 | |
| | 372 | // Filter the template locations so plugins can alter where they are located |
| | 373 | $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates ); |
| 377 | 374 | |
| | 375 | if ( ! empty( $located_template ) ) { |
| 378 | 376 | // Template was located, lets set this as a valid page and not a 404. |
| 379 | 377 | status_header( 200 ); |
| 380 | 378 | $wp_query->is_page = true; |