Skip to:
Content

BuddyPress.org

Changeset 13744


Ignore:
Timestamp:
02/29/2024 07:29:20 AM (11 months ago)
Author:
imath
Message:

BP Member’s nav: reset primary nav item links when a user is displayed

Since 12.0, the member’s nav item links are no more initialized with the logged-in user links but are left empty and built using the BP Rewrites API. It generated a compatibility issue when the BP Legacy URL parser is in use (eg: when the BP Classic Add-on is active): the BP Member’s nav used to populate a custom WP Nav Menu was wrongly using the displayed member’s links instead of the logged-in user ones.

Making sure to reset these links in favor of the logged-in user ones in such a case is now necessary during the custom WP Nav Menu generation process.

Props vapvarun espellcaste

See #9108 (trunk)
Closes https://github.com/buddypress/buddypress/pull/237

File:
1 edited

Legend:

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

    r13741 r13744  
    27922792
    27932793    if ( 'rewrites' !== bp_core_get_query_parser() ) {
    2794         $bp_menu_items = $bp->members->nav->get_primary();
     2794        $primary_items     = $bp->members->nav->get_primary();
     2795        $user_is_displayed = bp_is_user();
     2796
     2797        foreach( $primary_items as $primary_item ) {
     2798            $current_user_link = $primary_item['link'];
     2799
     2800            // When displaying a user, reset the primary item link.
     2801            if ( $user_is_displayed ) {
     2802                $current_user_link = bp_loggedin_user_url( bp_members_get_path_chunks( array( $primary_item['slug'] ) ) );
     2803            }
     2804
     2805            $bp_menu_items[] = array(
     2806                'name' => $primary_item['name'],
     2807                'slug' => $primary_item['slug'],
     2808                'link' => $current_user_link,
     2809            );
     2810        }
    27952811    } else {
    27962812        $members_navigation = bp_get_component_navigations();
Note: See TracChangeset for help on using the changeset viewer.