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-templates/bp-nouveau/includes/groups/functions.php

    r13441 r13442  
    44 *
    55 * @since 3.0.0
    6  * @version 10.0.0
     6 * @version 12.0.0
    77 */
    88
     
    457457function bp_nouveau_groups_invites_restriction_admin_nav( $wp_admin_nav ) {
    458458    // Setup the logged in user variables.
    459     $settings_link = trailingslashit( bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'settings' ) );
     459    $settings_slug = bp_nouveau_get_component_slug( 'settings' );
    460460
    461461    // Add the "Group Invites" subnav item.
     
    464464        'id'     => 'my-account-' . buddypress()->settings->id . '-invites',
    465465        'title'  => _x( 'Group Invites', 'Group invitations main menu title', 'buddypress' ),
    466         'href'   => trailingslashit( $settings_link . 'invites/' ),
     466        'href'   => bp_loggedin_user_url(
     467            array(
     468                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug, $settings_slug ),
     469                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $settings_slug . '_invites', 'invites' ),
     470            )
     471        ),
    467472    );
    468473
     
    562567
    563568    if ( is_user_logged_in() ) {
    564 
    565569        $my_groups_count = bp_get_total_group_count_for_user( bp_loggedin_user_id() );
     570        $groups_slug     = bp_nouveau_get_component_slug( 'groups' );
     571        $path_chunks     = array(
     572            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ),
     573        );
    566574
    567575        // If the user has groups create a nav item
    568576        if ( $my_groups_count ) {
     577            $path_chunks['single_item_action'] = bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_my_groups', 'my-groups' );
     578
    569579            $nav_items['personal'] = array(
    570580                'component' => 'groups',
    571581                'slug'      => 'personal', // slug is used because BP_Core_Nav requires it, but it's the scope
    572582                'li_class'  => array(),
    573                 'link'      => bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'groups' ) . '/my-groups/',
     583                'link'      => bp_loggedin_user_url( $path_chunks ),
    574584                'text'      => __( 'My Groups', 'buddypress' ),
    575585                'count'     => $my_groups_count,
Note: See TracChangeset for help on using the changeset viewer.