Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/23/2023 07:35:38 PM (19 months 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/screens/requests.php

    r13092 r13441  
    1414 */
    1515function friends_screen_requests() {
     16    $redirect = false;
     17
    1618    if ( bp_is_action_variable( 'accept', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
    1719        // Check the nonce.
    1820        check_admin_referer( 'friends_accept_friendship' );
    1921
    20         if ( friends_accept_friendship( bp_action_variable( 1 ) ) )
     22        if ( friends_accept_friendship( bp_action_variable( 1 ) ) ) {
    2123            bp_core_add_message( __( 'Friendship accepted', 'buddypress' ) );
    22         else
     24        } else {
    2325            bp_core_add_message( __( 'Friendship could not be accepted', 'buddypress' ), 'error' );
     26        }
    2427
    25         bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
     28        $redirect = true;
    2629
    2730    } elseif ( bp_is_action_variable( 'reject', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
     
    2932        check_admin_referer( 'friends_reject_friendship' );
    3033
    31         if ( friends_reject_friendship( bp_action_variable( 1 ) ) )
     34        if ( friends_reject_friendship( bp_action_variable( 1 ) ) ) {
    3235            bp_core_add_message( __( 'Friendship rejected', 'buddypress' ) );
    33         else
     36        } else {
    3437            bp_core_add_message( __( 'Friendship could not be rejected', 'buddypress' ), 'error' );
     38        }
    3539
    36         bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
     40        $redirect = true;
    3741
    3842    } elseif ( bp_is_action_variable( 'cancel', 0 ) && is_numeric( bp_action_variable( 1 ) ) ) {
     
    4044        check_admin_referer( 'friends_withdraw_friendship' );
    4145
    42         if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) )
     46        if ( friends_withdraw_friendship( bp_loggedin_user_id(), bp_action_variable( 1 ) ) ) {
    4347            bp_core_add_message( __( 'Friendship request withdrawn', 'buddypress' ) );
    44         else
     48        } else {
    4549            bp_core_add_message( __( 'Friendship request could not be withdrawn', 'buddypress' ), 'error' );
     50        }
    4651
    47         bp_core_redirect( trailingslashit( bp_loggedin_user_domain() . bp_current_component() . '/' . bp_current_action() ) );
     52        $redirect = true;
     53    }
     54
     55    if ( $redirect ) {
     56        $friends_slug = bp_get_friends_slug();
     57
     58        bp_core_redirect(
     59            bp_loggedin_user_url(
     60                array(
     61                    'single_item_component' => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug, $friends_slug ),
     62                    'single_item_action'    => bp_rewrites_get_slug( 'members', 'member_' . $friends_slug . '_requests', 'requests' ),
     63                )
     64            )
     65        );
    4866    }
    4967
Note: See TracChangeset for help on using the changeset viewer.