bp_blogs_activity_comment_single_action

Formats single activity comment entries to use the blog comment action.

Description

(string) bp_blogs_activity_comment_single_action( (string) $retval, (BP_Activity_Activity) $activity ); 

This is only done if the activity comment is associated with a blog comment.

Returns (string)

Parameters (2)

0. $retval (string)
The activity action.
1. $activity (BP_Activity_Activity)
Activity object.

Usage

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

Defined (1)

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

/bp-blogs/bp-blogs-activity.php  
  1. function bp_blogs_activity_comment_single_action( $retval, $activity ) { 
  2. if ( 'activity_comment' !== $activity->type ) { 
  3. return $retval; 
  4.  
  5. return $retval; 
  6.  
  7. $parent_activity = new BP_Activity_Activity( $activity->item_id ); 
  8.  
  9. if ( ! isset( $parent_activity->type ) ) { 
  10. return $retval; 
  11.  
  12. $post_type = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'post_type' ); 
  13.  
  14. if ( ! $post_type ) { 
  15. return $retval; 
  16.  
  17. $blog_comment_id = bp_activity_get_meta( $activity->id, "bp_blogs_{$post_type}_comment_id" ); 
  18.  
  19. if ( ! empty( $blog_comment_id ) ) { 
  20. $bp =buddypress); 
  21.  
  22. // Check if a comment action id is set for the parent activity 
  23. $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity->type, 'comment_action_id' ); 
  24.  
  25. // Use the action string callback for the activity type 
  26. if ( ! empty( $comment_action_id ) ) { 
  27. // Fake a 'new_{post_type}_comment' by cloning the activity object. 
  28. $object = clone $activity; 
  29.  
  30. // Set the type of the activity to be a comment about a post type 
  31. $object->type = $comment_action_id; 
  32.  
  33. // Use the blog ID as the item_id. 
  34. $object->item_id = $parent_activity->item_id; 
  35.  
  36. // Use comment ID as the secondary_item_id. 
  37. $object->secondary_item_id = $blog_comment_id; 
  38.  
  39. // Get the format callback for this activity comment 
  40. $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id, 'format_callback' ); 
  41.  
  42. // now format the activity action using the 'new_{post_type}_comment' action callback 
  43. if ( is_callable( $format_callback ) ) { 
  44. $retval = call_user_func_array( $format_callback, array( '', $object ) ); 
  45.  
  46. return $retval;