Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/31/2023 05:26:39 PM (3 years 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-xprofile/bp-xprofile-template.php

    r13393 r13443  
    390390
    391391                // Build the form action URL.
    392                 $form_action = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $group->id );
     392                $profile_slug = bp_get_profile_slug();
     393                $path_chunks  = array(
     394                        'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
     395                        'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
     396                        'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), $group->id ),
     397                );
     398                $form_action = bp_displayed_user_url( $path_chunks );
    393399
    394400                /**
     
    10741080
    10751081                // Build the profile field group link.
    1076                 $link   = trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit/group/' . $groups[ $i ]->id );
     1082                $profile_slug = bp_get_profile_slug();
     1083                $path_chunks  = array(
     1084                        'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
     1085                        'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
     1086                        'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit_group', 'group' ), $groups[ $i ]->id ),
     1087                );
     1088                $link         = bp_displayed_user_url( $path_chunks );
    10771089
    10781090                // Add tab to end of tabs array.
     
    12321244 */
    12331245function bp_edit_profile_button() {
     1246        $profile_slug = bp_get_profile_slug();
     1247        $path_chunks  = array(
     1248                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug, $profile_slug ),
     1249                'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $profile_slug . '_edit', 'edit' ),
     1250        );
     1251
    12341252        bp_button( array(
    12351253                'id'                => 'edit_profile',
     
    12371255                'must_be_logged_in' => true,
    12381256                'block_self'        => true,
    1239                 'link_href'         => trailingslashit( bp_displayed_user_domain() . bp_get_profile_slug() . '/edit' ),
     1257                'link_href'         => bp_displayed_user_url( $path_chunks ),
    12401258                'link_class'        => 'edit',
    12411259                'link_text'         => __( 'Edit Profile', 'buddypress' ),
Note: See TracChangeset for help on using the changeset viewer.