| 345 | | // reset post if not on a directory page |
| 346 | | // if we're not on a directory page, this means we're faking a page and we |
| 347 | | // need to reset the post to avoid notices |
| 348 | | if ( ! bp_is_directory() ) { |
| 349 | | bp_theme_compat_reset_post( array( |
| 350 | | 'ID' => 0, |
| 351 | | 'is_404' => true, |
| 352 | | 'post_status' => 'publish', |
| 353 | | ) ); |
| 354 | | |
| 355 | | // need to set theme compat to false since the reset post function |
| 356 | | // automatically sets theme compat to true |
| 357 | | bp_set_theme_compat_active( false ); |
| | 345 | // check if BP page belongs to, or is a child of, a BP directory page |
| | 346 | $page_id = false; |
| | 347 | foreach ( (array) buddypress()->pages as $page ) { |
| | 348 | if ( $page->name == buddypress()->unfiltered_uri[buddypress()->unfiltered_uri_offset] ) { |
| | 349 | $page_id = $page->id; |
| | 350 | break; |
| | 351 | } |
| | 352 | } |
| | 353 | |
| | 354 | // Set up reset post args |
| | 355 | $reset_post_args = array( |
| | 356 | 'is_404' => true, |
| | 357 | 'post_status' => 'publish', |
| | 358 | ); |
| | 359 | |
| | 360 | // BP page exists - fill in the $wp_query->post object |
| | 361 | // |
| | 362 | // bp_theme_compat_reset_post() looks at the $wp_query->post object to fill in |
| | 363 | // the post globals |
| | 364 | if ( ! empty( $page_id ) ) { |
| | 365 | $wp_query->post = get_post( $page_id ); |
| | 366 | $reset_post_args['ID'] = $page_id; |
| | 367 | } else { |
| | 368 | $reset_post_args['ID'] = 0; |