Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (2 years ago)
Author:
imath
Message:

BP Rewrites: optimize the code used to build URLs

The bp_members_get_path_chunks() & bp_groups_get_path_chunks() functions are making sure URL chunks are customized according to the slugs settings. Instead of redoing at many places all or some of the operations performed by these functions, update the code to build URLs so that it uses these functions.

See #4954
Fixes #8923
Closes https://github.com/buddypress/buddypress/pull/117

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r13500 r13503  
    38923892    function bp_get_member_activity_feed_link() {
    38933893        $activity_slug = bp_get_activity_slug();
    3894         $path_chunks   = array(
    3895             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    3896         );
     3894        $path_chunks   = array( $activity_slug );
    38973895
    38983896        // Single member activity feed link.
    38993897        if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
    3900             $path_chunks['single_item_action'] = 'feed';
    3901             $link                              = bp_displayed_user_url( $path_chunks );
     3898            $path_chunks[] = 'feed';
     3899            $link          = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    39023900
    39033901        // Friend feed link.
    39043902        } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
    3905             $friends_slug                                = bp_get_friends_slug();
    3906             $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $friends_slug, $friends_slug );
    3907             $path_chunks['single_item_action_variables'] = array( 'feed' );
    3908             $link                                        = bp_displayed_user_url( $path_chunks );
     3903            $path_chunks[] = bp_get_friends_slug();
     3904            $path_chunks[] = array( 'feed' );
     3905            $link          = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    39093906
    39103907        // Group feed link.
    39113908        } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
    3912             $groups_slug                                 = bp_get_groups_slug();
    3913             $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $groups_slug, $groups_slug );
    3914             $path_chunks['single_item_action_variables'] = array( 'feed' );
    3915             $link                                        = bp_displayed_user_url( $path_chunks );
     3909            $path_chunks[] = bp_get_groups_slug();
     3910            $path_chunks[] = array( 'feed' );
     3911            $link          = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    39163912
    39173913        // Favorites activity feed link.
    39183914        } elseif ( 'favorites' === bp_current_action() ) {
    3919             $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_'  . $activity_slug . '_favorites', 'favorites' );
    3920             $path_chunks['single_item_action_variables'] = array( 'feed' );
    3921             $link                                        = bp_displayed_user_url( $path_chunks );
     3915            $path_chunks[] = 'favorites';
     3916            $path_chunks[] = array( 'feed' );
     3917            $link          = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    39223918
    39233919        // Mentions activity feed link.
    39243920        } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
    3925             $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_'  . $activity_slug . '_mentions', 'mentions' );
    3926             $path_chunks['single_item_action_variables'] = array( 'feed' );
    3927             $link                                        = bp_displayed_user_url( $path_chunks );
     3921            $path_chunks[] = 'mentions';
     3922            $path_chunks[] = array( 'feed' );
     3923            $link          = bp_displayed_user_url( bp_members_get_path_chunks( $path_chunks ) );
    39283924
    39293925        // No feed link.
Note: See TracChangeset for help on using the changeset viewer.