Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/31/2023 05:26:39 PM (19 months ago)
Author:
imath
Message:

Make sure all displayed user URLs are built using the BP Rewrites API

Replace all remaining bp_displayed_user_domain() usage in favor of
bp_displayed_user_url().
Introduce the bp_members_get_path_chunks() function to quickly build BP
Rewrites argument for member's URL using an array of slugs.
Deprecate bp_activities_member_rss_link(), bp_blogs_blog_tabs() &
bp_groups_header_tabs().
Improve bp_displayed_user_link() so that it's possible to pass an array
of slugs to output an escaped BP Rewrites ready URL.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/79
See #4954

File:
1 edited

Legend:

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

    r13437 r13443  
    39093909 *
    39103910 * @since 1.2.0
    3911  *
    39123911 */
    39133912function bp_member_activity_feed_link() {
    3914     echo bp_get_member_activity_feed_link();
    3915 }
    3916 
    3917 /**
    3918  * Output the member activity feed link.
    3919  *
    3920  * @since 1.0.0
    3921  * @deprecated 1.2.0
    3922  *
    3923  * @todo properly deprecate in favor of bp_member_activity_feed_link().
    3924  *
    3925  */
    3926 function bp_activities_member_rss_link() { echo bp_get_member_activity_feed_link(); }
     3913    echo esc_url( bp_get_member_activity_feed_link() );
     3914}
    39273915
    39283916    /**
     
    39313919     * @since 1.2.0
    39323920     *
    3933      *
    39343921     * @return string $link The member activity feed link.
    39353922     */
    39363923    function bp_get_member_activity_feed_link() {
     3924        $activity_slug = bp_get_activity_slug();
     3925        $path_chunks   = array(
     3926            'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $activity_slug, $activity_slug ),
     3927        );
    39373928
    39383929        // Single member activity feed link.
    39393930        if ( bp_is_profile_component() || bp_is_current_action( 'just-me' ) ) {
    3940             $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/feed/';
     3931            $path_chunks['single_item_action'] = 'feed';
     3932            $link                              = bp_displayed_user_url( $path_chunks );
    39413933
    39423934        // Friend feed link.
    39433935        } elseif ( bp_is_active( 'friends' ) && bp_is_current_action( bp_get_friends_slug() ) ) {
    3944             $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_friends_slug() . '/feed/';
     3936            $friends_slug                                = bp_get_friends_slug();
     3937            $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $friends_slug, $friends_slug );
     3938            $path_chunks['single_item_action_variables'] = array( 'feed' );
     3939            $link                                        = bp_displayed_user_url( $path_chunks );
    39453940
    39463941        // Group feed link.
    39473942        } elseif ( bp_is_active( 'groups'  ) && bp_is_current_action( bp_get_groups_slug()  ) ) {
    3948             $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/' . bp_get_groups_slug() . '/feed/';
     3943            $groups_slug                                 = bp_get_groups_slug();
     3944            $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_' . $activity_slug . '_' . $groups_slug, $groups_slug );
     3945            $path_chunks['single_item_action_variables'] = array( 'feed' );
     3946            $link                                        = bp_displayed_user_url( $path_chunks );
    39493947
    39503948        // Favorites activity feed link.
    39513949        } elseif ( 'favorites' === bp_current_action() ) {
    3952             $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/favorites/feed/';
     3950            $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_'  . $activity_slug . '_favorites', 'favorites' );
     3951            $path_chunks['single_item_action_variables'] = array( 'feed' );
     3952            $link                                        = bp_displayed_user_url( $path_chunks );
    39533953
    39543954        // Mentions activity feed link.
    39553955        } elseif ( ( 'mentions' === bp_current_action() ) && bp_activity_do_mentions() ) {
    3956             $link = bp_displayed_user_domain() . bp_get_activity_slug() . '/mentions/feed/';
     3956            $path_chunks['single_item_action']           = bp_rewrites_get_slug( 'members', 'member_'  . $activity_slug . '_mentions', 'mentions' );
     3957            $path_chunks['single_item_action_variables'] = array( 'feed' );
     3958            $link                                        = bp_displayed_user_url( $path_chunks );
    39573959
    39583960        // No feed link.
Note: See TracChangeset for help on using the changeset viewer.