Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/09/2015 12:39:36 AM (11 years ago)
Author:
r-a-y
Message:

Properly highlight BuddyPress pages in a WordPress nav or page menu.

r8932 attempted to address how BuddyPress pages are highlighted in a
WordPress menu after the refactoring of bp_core_load_template() (see
r8821). r8932 resulted in declaring the BuddyPress parent page as the
current page even when it wasn't.

This commit removes this declaration and changes the highlighting method
to rely on the WP nav and page menu filters. This also fixes issues
with highlighting the BP parent page when the root profiles feature is
enabled (this previously did not work).

Fixes #5997.

File:
1 edited

Legend:

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

    r9315 r9322  
    343343    global $wp_query;
    344344
    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(
     345    // Reset the post
     346    bp_theme_compat_reset_post( array(
     347        'ID'          => 0,
    356348        'is_404'      => true,
    357349        '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;
    369     }
    370 
    371     // Reset the post
    372     bp_theme_compat_reset_post( $reset_post_args );
     350    ) );
    373351
    374352    // Set theme compat to false since the reset post function automatically sets
     
    394372    $located_template = apply_filters( 'bp_located_template', $template, $filtered_templates );
    395373    if ( !empty( $located_template ) ) {
    396 
    397374        // Template was located, lets set this as a valid page and not a 404.
    398375        status_header( 200 );
Note: See TracChangeset for help on using the changeset viewer.