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/ajax.php

    r13136 r13442  
    44 *
    55 * @since 3.0.0
    6  * @version 10.0.0
     6 * @version 12.0.0
    77 */
    88
     
    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
    5659        // We need to calculate and return the feed URL for each scope.
    5760        switch ( $scope ) {
    5861            case 'friends':
    59                 $feed_url = bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'activity' ) . '/friends/feed/';
     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                );
    6069                break;
    6170            case 'groups':
    62                 $feed_url = bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'activity' ) . '/groups/feed/';
     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                );
    6378                break;
    6479            case 'favorites':
    65                 $feed_url = bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'activity' ) . '/favorites/feed/';
     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                );
    6687                break;
    6788            case 'mentions':
    68                 $feed_url = bp_loggedin_user_domain() . bp_nouveau_get_component_slug( 'activity' ) . '/mentions/feed/';
     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                );
    6996
    7097                // Get user new mentions
Note: See TracChangeset for help on using the changeset viewer.