Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (18 months ago)
Author:
imath
Message:

Make BP_Core_Nav generate "BP Rewrites ready" navigation links

  • Remove all components $parent_url attributes when setting sub nav items.
  • Only use the bp_core_create_nav_link() $link attribute argument & the bp_core_create_subnav_link() $parent_url attribute argument if specified to preserve backward compatibility.
  • Migrates the Community search feature so that it uses BP Rewrites.
  • Perform some bp_loggedin_user_domain() in favor of bp_loggedin_user_url().
  • Update some PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/77
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-component.php

    r13432 r13441  
    230230    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    231231
    232         // Determine user to use.
    233         if ( bp_displayed_user_domain() ) {
    234             $user_domain = bp_displayed_user_domain();
    235         } elseif ( bp_loggedin_user_domain() ) {
    236             $user_domain = bp_loggedin_user_domain();
    237         } else {
     232        // Stop if there is no user displayed or logged in.
     233        if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
    238234            return;
    239235        }
    240236
    241         $access       = bp_core_can_edit_settings();
    242         $slug         = bp_get_profile_slug();
    243         $profile_link = trailingslashit( $user_domain . $slug );
     237        $access = bp_core_can_edit_settings();
     238        $slug   = bp_get_profile_slug();
    244239
    245240        // Add 'Profile' to the main navigation.
     
    257252            'name'            => _x( 'View', 'Profile header sub menu', 'buddypress' ),
    258253            'slug'            => 'public',
    259             'parent_url'      => $profile_link,
    260254            'parent_slug'     => $slug,
    261255            'screen_function' => 'xprofile_screen_display_profile',
     
    267261            'name'            => _x( 'Edit','Profile header sub menu', 'buddypress' ),
    268262            'slug'            => 'edit',
    269             'parent_url'      => $profile_link,
    270263            'parent_slug'     => $slug,
    271264            'screen_function' => 'xprofile_screen_edit_profile',
     
    294287        }
    295288
    296         // Determine user to use.
    297         if ( bp_displayed_user_domain() ) {
    298             $user_domain = bp_displayed_user_domain();
    299         } elseif ( bp_loggedin_user_domain() ) {
    300             $user_domain = bp_loggedin_user_domain();
    301         } else {
     289        // Stop if there is no user displayed or logged in.
     290        if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
    302291            return;
    303292        }
     
    309298            'name'            => _x( 'Profile Visibility', 'Profile settings sub nav', 'buddypress' ),
    310299            'slug'            => 'profile',
    311             'parent_url'      => trailingslashit( $user_domain . $settings_slug ),
    312300            'parent_slug'     => $settings_slug,
    313301            'screen_function' => 'bp_xprofile_screen_settings',
Note: See TracChangeset for help on using the changeset viewer.