bp_activity_format_activity_action_custom_post_type_comment( string $action, object $activity )
Format activity action strings for custom post types comments.
Parameters Parameters
- $action
-
(string) (Required) Static activity action.
- $activity
-
(object) (Required) Activity data object.
Return Return
(string)
Source Source
File: bp-activity/bp-activity-functions.php
function bp_activity_format_activity_action_custom_post_type_comment( $action, $activity ) { $bp = buddypress(); // Fetch all the tracked post types once. if ( empty( $bp->activity->track ) ) { $bp->activity->track = bp_activity_get_post_types_tracking_args(); } if ( empty( $activity->type ) || empty( $bp->activity->track[ $activity->type ] ) ) { return $action; } $user_link = bp_core_get_userlink( $activity->user_id ); $post_link = '<a href="' . esc_url( $activity->primary_link ) . '">' . esc_html_x( 'item', 'Default text for the post type name', 'buddypress' ) . '</a>'; if ( is_multisite() ) { $blog_link = '<a href="' . esc_url( get_home_url( $activity->item_id ) ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>'; if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms ) ) { $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms, $user_link, $activity->primary_link, $blog_link ); } else { /* translators: 1: the activity author user link. 2: the post link. 3: the blog link. */ $action = sprintf( esc_html_x( '%1$s commented on the %2$s, on the site %3$s', 'Activity Custom Post Type comment action', 'buddypress' ), $user_link, $post_link, $blog_link ); } } else { if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action ) ) { $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action, $user_link, $activity->primary_link ); } else { /* translators: 1: the activity author user link. 2: the post link. */ $action = sprintf( esc_html_x( '%1$s commented on the %2$s', 'Activity Custom Post Type post comment action', 'buddypress' ), $user_link, $post_link ); } } /** * Filters the formatted custom post type activity comment action string. * * @since 2.5.0 * * @param string $action Activity action string value. * @param BP_Activity_Activity $activity Activity item object. */ return apply_filters( 'bp_activity_custom_post_type_comment_action', $action, $activity ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.5.0 | Introduced. |