Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (13 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-core/bp-core-buddybar.php

    r13436 r13441  
    161161        'name'                    => $r['name'],
    162162        'slug'                    => $r['slug'],
    163         'link'                    => trailingslashit( bp_loggedin_user_domain() . $r['slug'] ),
    164163        'css_id'                  => $r['item_css_id'],
    165164        'show_for_displayed_user' => $r['show_for_displayed_user'],
     
    561560
    562561    // If we don't have the required info we need, don't create this subnav item.
    563     if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['parent_url'] ) || empty( $r['screen_function'] ) )
    564         return false;
    565 
    566     // Link was not forced, so create one.
    567     if ( empty( $r['link'] ) ) {
     562    if ( empty( $r['name'] ) || empty( $r['slug'] ) || empty( $r['parent_slug'] ) || empty( $r['screen_function'] ) ) {
     563        return false;
     564    }
     565
     566    // Preserve backward compatibility for plugins forcing URLs.
     567    if ( empty( $r['link'] ) && ! empty( $r['parent_url'] ) ) {
    568568        $r['link'] = trailingslashit( $r['parent_url'] . $r['slug'] );
    569 
    570         $parent_nav = $bp->{$component}->nav->get_primary( array( 'slug' => $r['parent_slug'] ), false );
    571 
    572         // If this sub item is the default for its parent, skip the slug.
    573         if ( $parent_nav ) {
    574             $parent_nav_item = reset( $parent_nav );
    575             if ( ! empty( $parent_nav_item->default_subnav_slug ) && $r['slug'] === $parent_nav_item->default_subnav_slug ) {
    576                 $r['link'] = trailingslashit( $r['parent_url'] );
    577             }
    578         }
    579569    }
    580570
     
    601591    );
    602592
     593    // Add the item to the subnav.
    603594    buddypress()->{$component}->nav->add_nav( $subnav_item );
    604595
Note: See TracChangeset for help on using the changeset viewer.