Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (4 years ago)
Author:
imath
Message:

Make BP_Core_Nav generate "BP Rewrites ready" navigation links

  • Remove all components $parent_url attributes when setting sub nav items.
  • Only use the bp_core_create_nav_link() $link attribute argument & the bp_core_create_subnav_link() $parent_url attribute argument if specified to preserve backward compatibility.
  • Migrates the Community search feature so that it uses BP Rewrites.
  • Perform some bp_loggedin_user_domain() in favor of bp_loggedin_user_url().
  • Update some PHPUnit tests.

Props r-a-y, johnjamesjacoby, boonebgorges

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

File:
1 edited

Legend:

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

    r13434 r13441  
    378378
    379379                $friendship_status = bp_is_friend( $potential_friend_id );
     380                $friends_slug        = bp_get_friends_slug();
     381                $custom_friends_slug = bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug );
    380382
    381383                if ( empty( $friendship_status ) ) {
    … …  
    392394                                        'wrapper_class'     => 'friendship-button pending_friend',
    393395                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    394                                         'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $potential_friend_id . '/', 'friends_withdraw_friendship' ),
     396                                        'link_href'         => wp_nonce_url(
     397                                                bp_loggedin_user_url(
     398                                                        array(
     399                                                                'single_item_component'        => $custom_friends_slug,
     400                                                                'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
     401                                                                'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests_cancel', 'cancel' ), $potential_friend_id ),
     402                                                        )
     403                                                ),
     404                                                'friends_withdraw_friendship'
     405                                        ),
    395406                                        'link_text'         => __( 'Cancel Friendship Request', 'buddypress' ),
    396407                                        'link_title'        => __( 'Cancel Friendship Requested', 'buddypress' ),
    … …  
    409420                                        'wrapper_class'     => 'friendship-button awaiting_response_friend',
    410421                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    411                                         'link_href'         => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/',
     422                                        'link_href'         => bp_loggedin_user_url(
     423                                                array(
     424                                                        'single_item_component' => $custom_friends_slug,
     425                                                        'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
     426                                                )
     427                                        ),
    412428                                        'link_text'         => __( 'Friendship Requested', 'buddypress' ),
    413429                                        'link_title'        => __( 'Friendship Requested', 'buddypress' ),
    … …  
    426442                                        'wrapper_class'     => 'friendship-button is_friend',
    427443                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    428                                         'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ),
     444                                        'link_href'         => wp_nonce_url(
     445                                                bp_loggedin_user_url(
     446                                                        array(
     447                                                                'single_item_component'        => $custom_friends_slug,
     448                                                                'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_remove_friend', 'remove-friend' ),
     449                                                                'single_item_action_variables' => array( $potential_friend_id ),
     450                                                        )
     451                                                ),
     452                                                'friends_remove_friend'
     453                                        ),
    429454                                        'link_text'         => __( 'Cancel Friendship', 'buddypress' ),
    430455                                        'link_title'        => __( 'Cancel Friendship', 'buddypress' ),
    … …  
    443468                                        'wrapper_class'     => 'friendship-button not_friends',
    444469                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    445                                         'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ),
     470                                        'link_href'         => wp_nonce_url(
     471                                                bp_loggedin_user_url(
     472                                                        array(
     473                                                                'single_item_component'        => $custom_friends_slug,
     474                                                                'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_add_friend', 'add-friend' ),
     475                                                                'single_item_action_variables' => array( $potential_friend_id ),
     476                                                        )
     477                                                ),
     478                                                'friends_add_friend'
     479                                        ),
    446480                                        'link_text'         => __( 'Add Friend', 'buddypress' ),
    447481                                        'link_title'        => __( 'Add Friend', 'buddypress' ),
    … …  
    610644                }
    611645
     646                $friends_slug = bp_get_friends_slug();
     647                $url          = wp_nonce_url(
     648                        bp_loggedin_user_url(
     649                                array(
     650                                        'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug ),
     651                                        'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
     652                                        'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests_accept', 'accept' ), $friendship_id ),
     653                                )
     654                        ),
     655                        'friends_accept_friendship'
     656                );
     657
    612658                /**
    613659                 * Filters the URL for accepting the current friendship request in the loop.
    … …  
    616662                 * @since 2.6.0 Added the `$friendship_id` parameter.
    617663                 *
    618                  * @param string $value         Accept-friendship URL.
     664                 * @param string $url           Accept-friendship URL.
    619665                 * @param int    $friendship_id ID of the friendship.
    620666                 */
    621                 return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id ), 'friends_accept_friendship' ), $friendship_id );
     667                return apply_filters( 'bp_get_friend_accept_request_link', $url, $friendship_id );
    622668        }
    623669
    … …  
    647693                }
    648694
     695                $friends_slug = bp_get_friends_slug();
     696                $url          = wp_nonce_url(
     697                        bp_loggedin_user_url(
     698                                array(
     699                                        'single_item_component'        => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug ),
     700                                        'single_item_action'           => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
     701                                        'single_item_action_variables' => array( bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests_reject', 'reject' ), $friendship_id ),
     702                                )
     703                        ),
     704                        'friends_reject_friendship'
     705                );
     706
    649707                /**
    650708                 * Filters the URL for rejecting the current friendship request in the loop.
    … …  
    653711                 * @since 2.6.0 Added the `$friendship_id` parameter.
    654712                 *
    655                  * @param string $value         Reject-friendship URL.
     713                 * @param string $url           Reject-friendship URL.
    656714                 * @param int    $friendship_id ID of the friendship.
    657715                 */
    658                 return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id ), 'friends_reject_friendship' ), $friendship_id );
     716                return apply_filters( 'bp_get_friend_reject_request_link', $url, $friendship_id );
    659717        }
    660718
Note: See TracChangeset for help on using the changeset viewer.