bp_activity_generate_action_string( object $activity )
Generate an activity action string for an activity item.
Description
Parameters
- $activity
-
(Required) Activity data object.
Return
(string|bool) Returns false if no callback is found, otherwise returns the formatted action string.
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_generate_action_string( $activity ) {
// Check for valid input.
if ( empty( $activity->component ) || empty( $activity->type ) ) {
return false;
}
// Check for registered format callback.
$actions = bp_activity_get_actions();
if ( empty( $actions->{$activity->component}->{$activity->type}['format_callback'] ) ) {
return false;
}
// We apply the format_callback as a filter.
add_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10, 2 );
/**
* Filters the string for the activity action being returned.
*
* @since BuddyPress 2.0.0
*
* @param BP_Activity_Activity $action Action string being requested.
* @param BP_Activity_Activity $activity Activity item object.
*/
$action = apply_filters( 'bp_activity_generate_action_string', $activity->action, $activity );
// Remove the filter for future activity items.
remove_filter( 'bp_activity_generate_action_string', $actions->{$activity->component}->{$activity->type}['format_callback'], 10 );
return $action;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.0.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.