Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/27/2023 06:19:06 PM (13 months ago)
Author:
imath
Message:

Improve Components Member's single item navigation generation

  • Edit the BP_Component Class so that it globalize navigation items before registering it.
  • Introduce bp_get_component_navigations(), a new function that will be used to get Member's single navigation customizable slugs within the BuddyPress settings area.
  • Perform all remaining bp_loggedin_user_domain() replacements (55) in favor of the bp_loggedin_user_url() function which uses BP Rewrites to build URLs.
  • Improve bp_loggedin_user_link() by adding a new $chunks array of arguments to output escaped URL in templates.
  • Adapt some PHPUnit testcases.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13441 r13442  
    316316        // Menus for logged in user.
    317317        if ( is_user_logged_in() ) {
    318 
    319             // Profile link.
    320             $profile_link = trailingslashit( bp_loggedin_user_domain() . bp_get_profile_slug() );
     318            $profile_slug = bp_get_profile_slug();
     319            $path_chunks  = array(
     320                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
     321            );
    321322
    322323            // Add the "Profile" sub menu.
     
    325326                'id'     => 'my-account-' . $this->id,
    326327                'title'  => _x( 'Profile', 'My Account Profile', 'buddypress' ),
    327                 'href'   => $profile_link,
     328                'href'   => bp_loggedin_user_url( $path_chunks ),
    328329            );
     330
     331            $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_public', 'public' );
    329332
    330333            // View Profile.
     
    333336                'id'       => 'my-account-' . $this->id . '-public',
    334337                'title'    => _x( 'View', 'My Account Profile sub nav', 'buddypress' ),
    335                 'href'     => trailingslashit( $profile_link . 'public' ),
     338                'href'     => bp_loggedin_user_url( $path_chunks ),
    336339                'position' => 10,
    337340            );
     341
     342            $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' );
    338343
    339344            // Edit Profile.
     
    342347                'id'       => 'my-account-' . $this->id . '-edit',
    343348                'title'    => _x( 'Edit', 'My Account Profile sub nav', 'buddypress' ),
    344                 'href'     => trailingslashit( $profile_link . 'edit' ),
     349                'href'     => bp_loggedin_user_url( $path_chunks ),
    345350                'position' => 20,
    346351            );
     
    417422
    418423        // Setup the logged in user variables.
    419         $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );
     424        $settings_slug = bp_get_settings_slug();
     425        $path_chunks   = array(
     426            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug, $settings_slug ),
     427            'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug . '_profile', 'profile' ),
     428        );
    420429
    421430        // Add the "Profile" subnav item.
     
    424433            'id'     => 'my-account-' . buddypress()->settings->id . '-profile',
    425434            'title'  => _x( 'Profile', 'My Account Settings sub nav', 'buddypress' ),
    426             'href'   => trailingslashit( $settings_link . 'profile' ),
     435            'href'   => bp_loggedin_user_url( $path_chunks ),
    427436        );
    428437
Note: See TracChangeset for help on using the changeset viewer.