bp_activity_format_activity_action_custom_post_type_comment

Format activity action strings for custom post types comments.

Description

(string) bp_activity_format_activity_action_custom_post_type_comment( (string) $action, (object) $activity ); 

Returns (string)

Parameters (2)

0. $action (string)
Static activity action.
1. $activity (object)
Activity data object.

Usage

  1. if ( !function_exists( 'bp_activity_format_activity_action_custom_post_type_comment' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-functions.php'; 
  3.  
  4. // Static activity action. 
  5. $action = ''; 
  6.  
  7. // Activity data object. 
  8. $activity = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_activity_format_activity_action_custom_post_type_comment($action, $activity); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-activity/bp-activity-functions.php  
  1. function bp_activity_format_activity_action_custom_post_type_comment( $action, $activity ) { 
  2. $bp =buddypress); 
  3.  
  4. // Fetch all the tracked post types once. 
  5. if ( empty( $bp->activity->track ) ) { 
  6. $bp->activity->track = bp_activity_get_post_types_tracking_args(); 
  7.  
  8. if ( empty( $activity->type ) || empty( $bp->activity->track[ $activity->type ] ) ) { 
  9. return $action; 
  10.  
  11. $user_link = bp_core_get_userlink( $activity->user_id ); 
  12.  
  13. if ( is_multisite() ) { 
  14. $blog_link = '<a href="' . esc_url( get_home_url( $activity->item_id ) ) . '">' . get_blog_option( $activity->item_id, 'blogname' ) . '</a>'; 
  15.  
  16. if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms ) ) { 
  17. $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action_ms, $user_link, $activity->primary_link, $blog_link ); 
  18. } else { 
  19. $action = sprintf( _x( '%1$s commented on the <a href="%2$s">item</a>, on the site %3$s', 'Activity Custom Post Type comment action', buddypress ), $user_link, $activity->primary_link, $blog_link ); 
  20. } else { 
  21. if ( ! empty( $bp->activity->track[ $activity->type ]->new_post_type_comment_action ) ) { 
  22. $action = sprintf( $bp->activity->track[ $activity->type ]->new_post_type_comment_action, $user_link, $activity->primary_link ); 
  23. } else { 
  24. $action = sprintf( _x( '%1$s commented on the <a href="%2$s">item</a>', 'Activity Custom Post Type post comment action', buddypress ), $user_link, $activity->primary_link ); 
  25.  
  26. /** 
  27. * Filters the formatted custom post type activity comment action string. 
  28. * @since 2.5.0 
  29. * @param string $action Activity action string value. 
  30. * @param BP_Activity_Activity $activity Activity item object. 
  31. */