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

    r13442 r13503  
    5454        }
    5555
    56         $activity_slug        = bp_nouveau_get_component_slug( 'activity' );
    57         $custom_activity_slug = bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug );
    58 
    5956        // We need to calculate and return the feed URL for each scope.
    6057        switch ( $scope ) {
    6158            case 'friends':
    62                 $feed_url = bp_loggedin_user_url(
    63                     array(
    64                         'single_item_component'        => $custom_activity_slug,
    65                         'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_friends', 'friends' ),
    66                         'single_item_action_variables' => array( 'feed' ),
    67                     )
    68                 );
     59                $feed_url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_nouveau_get_component_slug( 'activity' ), 'friends', array( 'feed' ) ) ) );
    6960                break;
    7061            case 'groups':
    71                 $feed_url = bp_loggedin_user_url(
    72                     array(
    73                         'single_item_component'        => $custom_activity_slug,
    74                         'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_groups', 'groups' ),
    75                         'single_item_action_variables' => array( 'feed' ),
    76                     )
    77                 );
     62                $feed_url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_nouveau_get_component_slug( 'activity' ), 'groups', array( 'feed' ) ) ) );
    7863                break;
    7964            case 'favorites':
    80                 $feed_url = bp_loggedin_user_url(
    81                     array(
    82                         'single_item_component'        => $custom_activity_slug,
    83                         'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_favorites', 'favorites' ),
    84                         'single_item_action_variables' => array( 'feed' ),
    85                     )
    86                 );
     65                $feed_url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_nouveau_get_component_slug( 'activity' ), 'favorites', array( 'feed' ) ) ) );
    8766                break;
    8867            case 'mentions':
    89                 $feed_url = bp_loggedin_user_url(
    90                     array(
    91                         'single_item_component'        => $custom_activity_slug,
    92                         'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_mentions', 'mentions' ),
    93                         'single_item_action_variables' => array( 'feed' ),
    94                     )
    95                 );
     68                $feed_url = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_nouveau_get_component_slug( 'activity' ), 'mentions', array( 'feed' ) ) ) );
    9669
    9770                // Get user new mentions
Note: See TracChangeset for help on using the changeset viewer.