Changeset 3488 for trunk/bp-core/bp-core-catchuri.php
- Timestamp:
- 11/27/2010 10:21:26 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/bp-core/bp-core-catchuri.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-core/bp-core-catchuri.php
r3464 r3488 105 105 106 106 // Reset the keys by merging with an empty array 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 107 $bp_uri = array_merge( array(), $bp_uri ); 108 $bp_unfiltered_uri = $bp_uri; 109 110 // If a component is set to the front page, force its name into $bp_uri so that $current_component is populated 111 if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && empty( $bp_uri ) ) { 112 $post = get_post( get_option( 'page_on_front' ) ); 113 if ( !empty( $post ) ) 114 $bp_uri[0] = $post->post_name; 115 } 109 116 110 117 // Find a match within registered BuddyPress controlled WP pages (check members first) … … 215 222 * @package BuddyPress Core 216 223 * @param $username str Username to check. 217 * @global $wpdb WordPress DB access object. 218 * @return false on no match 219 * @return int the user ID of the matched user. 224 * @return false|int The user ID of the matched user, or false. 220 225 */ 221 226 function bp_core_load_template( $templates ) { 222 global $ post, $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;227 global $bp, $wpdb, $wp_query, $bp_unfiltered_uri, $bp_unfiltered_uri_offset; 223 228 224 229 // Determine if the root object WP page exists for this request (TODO: is there an API function for this? 225 if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) ) 226 return false; 227 228 // Set the root object as the current wp_query-ied item 229 $object_id = 0; 230 foreach ( (array)$bp->pages as $page ) { 231 if ( isset( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) && $page->name == $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) 232 $object_id = $page->id; 233 } 234 235 // Make the queried/post object an actual valid page 236 if ( !empty( $object_id ) ) { 237 $wp_query->queried_object = &get_post( $object_id ); 238 $wp_query->queried_object_id = $object_id; 239 240 $post = $wp_query->queried_object; 241 } 230 if ( !empty( $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) 231 if ( !$page_exists = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_name = %s", $bp_unfiltered_uri[$bp_unfiltered_uri_offset] ) ) ) 232 return false; 242 233 243 234 // Fetch each template and add the php suffix … … 246 237 247 238 // Filter the template locations so that plugins can alter where they are located 248 if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) { 249 // Template was located, lets set this as a valid page and not a 404. 250 status_header( 200 ); 251 $wp_query->is_page = true; 252 $wp_query->is_404 = false; 253 239 if ( $located_template = apply_filters( 'bp_located_template', locate_template( (array) $filtered_templates, false ), $filtered_templates ) ) 254 240 load_template( apply_filters( 'bp_load_template', $located_template ) ); 255 }256 241 257 242 // Kill any other output after this.
Note: See TracChangeset
for help on using the changeset viewer.