Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/18/2023 04:11:04 AM (22 months 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/actions/feeds.php

    r13443 r13503  
    5555    }
    5656
    57     $activity_slug = bp_get_activity_slug();
    58     $link          = bp_displayed_user_url(
    59         array(
    60             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    61         )
    62     );
     57    $link = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_activity_slug() ) ) );
    6358
    6459    // Setup the feed.
     
    9590    }
    9691
    97     $activity_slug = bp_get_activity_slug();
    98     $friends_slug  = bp_get_friends_slug();
    99     $link          = bp_displayed_user_url(
    100         array(
    101             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    102             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $friends_slug, $friends_slug ),
    103         )
    104     );
     92    $link = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_activity_slug(), bp_get_friends_slug() ) ) );
    10593
    10694    // Setup the feed.
     
    138126
    139127    // Get displayed user's group IDs.
    140     $groups        = groups_get_user_groups();
    141     $group_ids     = implode( ',', $groups['groups'] );
    142     $activity_slug = bp_get_activity_slug();
    143     $groups_slug   = bp_get_groups_slug();
    144     $link          = bp_displayed_user_url(
    145         array(
    146             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    147             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $groups_slug, $groups_slug ),
    148         )
    149     );
     128    $groups    = groups_get_user_groups();
     129    $group_ids = implode( ',', $groups['groups'] );
     130    $link      = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_activity_slug(), bp_get_groups_slug() ) ) );
    150131
    151132    // Setup the feed.
     
    190171    }
    191172
    192     $activity_slug = bp_get_activity_slug();
    193     $link          = bp_displayed_user_url(
    194         array(
    195             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    196             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_mentions', 'mentions' ),
    197         )
    198     );
     173    $link = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_activity_slug(), 'mentions' ) ) );
    199174
    200175    // Setup the feed.
     
    234209
    235210    // Get displayed user's favorite activity IDs.
    236     $favs          = bp_activity_get_user_favorites( bp_displayed_user_id() );
    237     $fav_ids       = implode( ',', (array) $favs );
    238     $activity_slug = bp_get_activity_slug();
    239     $link          = bp_displayed_user_url(
    240         array(
    241             'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
    242             'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_favorites', 'favorites' ),
    243         )
    244     );
     211    $favs    = bp_activity_get_user_favorites( bp_displayed_user_id() );
     212    $fav_ids = implode( ',', (array) $favs );
     213    $link    = bp_displayed_user_url( bp_members_get_path_chunks( array( bp_get_activity_slug(), 'favorites' ) ) );
    245214
    246215    // Setup the feed.
Note: See TracChangeset for help on using the changeset viewer.