bp_activity_get_permalink( int $activity_id, object|bool $activity_obj = false )
Get the permalink for a single activity item.
Description
When only the $activity_id param is passed, BP has to instantiate a new BP_Activity_Activity object. To save yourself some processing overhead, be sure to pass the full $activity_obj parameter as well, if you already have it available.
Parameters
- $activity_id
-
(Required) The unique id of the activity object.
- $activity_obj
-
(Optional) The activity object.
Default value: false
Return
(string) $link Permalink for the activity item.
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_get_permalink( $activity_id, $activity_obj = false ) { $bp = buddypress(); if ( empty( $activity_obj ) ) { $activity_obj = new BP_Activity_Activity( $activity_id ); } if ( isset( $activity_obj->current_comment ) ) { $activity_obj = $activity_obj->current_comment; } $use_primary_links = array( 'new_blog_post', 'new_blog_comment', 'new_forum_topic', 'new_forum_post', ); if ( ! empty( $bp->activity->track ) ) { $use_primary_links = array_merge( $use_primary_links, array_keys( $bp->activity->track ) ); } if ( false !== array_search( $activity_obj->type, $use_primary_links ) ) { $link = $activity_obj->primary_link; } else { if ( 'activity_comment' == $activity_obj->type ) { $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->item_id . '/#acomment-' . $activity_obj->id; } else { $link = bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $activity_obj->id . '/'; } } /** * Filters the activity permalink for the specified activity item. * * @since BuddyPress 1.2.0 * * @param array $array Array holding activity permalink and activity item object. */ return apply_filters_ref_array( 'bp_activity_get_permalink', array( $link, &$activity_obj ) ); }
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.