Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (3 years 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-blogs/classes/class-bp-blogs-component.php

    r13436 r13441  
    219219                }
    220220
    221                 // Determine user to use.
    222                 if ( bp_displayed_user_domain() ) {
    223                         $user_domain = bp_displayed_user_domain();
    224                 } elseif ( bp_loggedin_user_domain() ) {
    225                         $user_domain = bp_loggedin_user_domain();
    226                 } else {
     221                // Stop if there is no user displayed or logged in.
     222                if ( ! is_user_logged_in() && ! bp_displayed_user_id() ) {
    227223                        return;
    228224                }
    229225
    230226                $slug       = bp_get_blogs_slug();
    231                 $parent_url = trailingslashit( $user_domain . $slug );
    232227
    233228                // Add 'Sites' to the main navigation.
     
    255250                        'name'            => __( 'My Sites', 'buddypress' ),
    256251                        'slug'            => 'my-sites',
    257                         'parent_url'      => $parent_url,
    258252                        'parent_slug'     => $slug,
    259253                        'screen_function' => 'bp_blogs_screen_my_blogs',
     
    290284
    291285                        // Setup the logged in user variables.
    292                         $blogs_link = trailingslashit( bp_loggedin_user_domain() . bp_get_blogs_slug() );
     286                        $blogs_slug        = bp_get_blogs_slug();
     287                        $custom_blogs_slug = bp_rewrites_get_slug( 'members', 'member_' . $blogs_slug, $blogs_slug );
    293288
    294289                        // Add the "Sites" sub menu.
     
    297292                                'id'     => 'my-account-' . $this->id,
    298293                                'title'  => __( 'Sites', 'buddypress' ),
    299                                 'href'   => $blogs_link
     294                                'href'   => bp_loggedin_user_url(
     295                                        array(
     296                                                'single_item_component' => $custom_blogs_slug,
     297                                        )
     298                                ),
    300299                        );
    301300
     
    305304                                'id'       => 'my-account-' . $this->id . '-my-sites',
    306305                                'title'    => __( 'My Sites', 'buddypress' ),
    307                                 'href'     => trailingslashit( $blogs_link . 'my-sites' ),
    308                                 'position' => 10
     306                                'href'     => bp_loggedin_user_url(
     307                                        array(
     308                                                'single_item_component' => $custom_blogs_slug,
     309                                                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $blogs_slug . '_my_sites', 'my-sites' ),
     310                                        )
     311                                ),
     312                                'position' => 10,
    309313                        );
    310314
Note: See TracChangeset for help on using the changeset viewer.