Skip to:
Content

BuddyPress.org

Changeset 13715


Ignore:
Timestamp:
01/27/2024 03:39:38 AM (10 months ago)
Author:
imath
Message:

Ensure single activity permalink router is reliable with plain links

When building the URL to redirect a single activity request to the member's activity single view, make sure to remove potential BP URI query variables relative to the Activity component before trying to transport extra query variables to the redirect URL.

Props johnjamesjacoby

Fixes #9082 (branch 12.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/12.0/src/bp-activity/screens/permalink.php

    r13503 r13715  
    6363    }
    6464
    65     // If set, add the original query string back onto the redirect URL.
    66     if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
     65    // Make sure current BP URI query variables are removed.
     66    $current_url = remove_query_arg( array( 'bp_activities', 'bp_activity_action', 'bp_activity_action_variables' ) );
     67    $extra_args  = wp_parse_url( $current_url, PHP_URL_QUERY );
     68
     69    // If there are query variables left, add them back onto the redirect URL.
     70    if ( $extra_args ) {
    6771        $query_frags = array();
    68         wp_parse_str( $_SERVER['QUERY_STRING'], $query_frags );
     72        wp_parse_str( $extra_args, $query_frags );
     73
     74        // Add extra arguments to the redirect URL.
    6975        $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect );
    7076    }
Note: See TracChangeset for help on using the changeset viewer.