Skip to:
Content

BuddyPress.org

Changeset 13745


Ignore:
Timestamp:
02/29/2024 07:40:44 AM (3 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

Fixes #9108 (branch 12.0)

File:
1 edited

Legend:

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

    r13706 r13745  
    28222822
    28232823    if ( 'rewrites' !== bp_core_get_query_parser() ) {
    2824         $bp_menu_items = $bp->members->nav->get_primary();
     2824        $primary_items     = $bp->members->nav->get_primary();
     2825        $user_is_displayed = bp_is_user();
     2826
     2827        foreach( $primary_items as $primary_item ) {
     2828            $current_user_link = $primary_item['link'];
     2829
     2830            // When displaying a user, reset the primary item link.
     2831            if ( $user_is_displayed ) {
     2832                $current_user_link = bp_loggedin_user_url( bp_members_get_path_chunks( array( $primary_item['slug'] ) ) );
     2833            }
     2834
     2835            $bp_menu_items[] = array(
     2836                'name' => $primary_item['name'],
     2837                'slug' => $primary_item['slug'],
     2838                'link' => $current_user_link,
     2839            );
     2840        }
    28252841    } else {
    28262842        $members_navigation = bp_get_component_navigations();
Note: See TracChangeset for help on using the changeset viewer.