bp_activity_action_permalink_router()
Catch and route requests for single activity item permalinks.
Description
Return
(bool) False on failure.
Source
File: bp-activity/screens/permalink.php
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | function bp_activity_action_permalink_router() { // Not viewing activity. if ( ! bp_is_activity_component() || ! bp_is_current_action( 'p' ) ) return false; // No activity to display. if ( ! bp_action_variable( 0 ) || ! is_numeric ( bp_action_variable( 0 ) ) ) return false; // Get the activity details. $activity = bp_activity_get_specific( array ( 'activity_ids' => bp_action_variable( 0 ), 'show_hidden' => true ) ); // 404 if activity does not exist if ( empty ( $activity [ 'activities' ][0] ) ) { bp_do_404(); return ; } else { $activity = $activity [ 'activities' ][0]; } // Do not redirect at default. $redirect = false; // Redirect based on the type of activity. if ( bp_is_active( 'groups' ) && $activity ->component == buddypress()->groups->id ) { // Activity is a user update. if ( ! empty ( $activity ->user_id ) ) { $redirect = bp_core_get_user_domain( $activity ->user_id, $activity ->user_nicename, $activity ->user_login ) . bp_get_activity_slug() . '/' . $activity ->id . '/' ; // Activity is something else. } else { // Set redirect to group activity feed. if ( $group = groups_get_group( $activity ->item_id ) ) { $redirect = bp_get_group_permalink( $group ) . bp_get_activity_slug() . '/' . $activity ->id . '/' ; } } // Set redirect to users' activity feed. } elseif ( ! empty ( $activity ->user_id ) ) { $redirect = bp_core_get_user_domain( $activity ->user_id, $activity ->user_nicename, $activity ->user_login ) . bp_get_activity_slug() . '/' . $activity ->id . '/' ; } // If set, add the original query string back onto the redirect URL. if ( ! empty ( $_SERVER [ 'QUERY_STRING' ] ) ) { $query_frags = array (); wp_parse_str( $_SERVER [ 'QUERY_STRING' ], $query_frags ); $redirect = add_query_arg( urlencode_deep( $query_frags ), $redirect ); } /** * Filter the intended redirect url before the redirect occurs for the single activity item. * * @since BuddyPress 1.2.2 * * @param array $value Array with url to redirect to and activity related to the redirect. */ if ( ! $redirect = apply_filters_ref_array( 'bp_activity_permalink_redirect_url' , array ( $redirect , & $activity ) ) ) { bp_core_redirect( bp_get_root_domain() ); } // Redirect to the actual activity permalink page. bp_core_redirect( $redirect ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.2.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.