bp_blogs_activity_comment_single_action( string $retval, BP_Activity_Activity $activity )
Formats single activity comment entries to use the blog comment action.
Description
This is only done if the activity comment is associated with a blog comment.
Parameters
- $retval
-
(Required) The activity action.
- $activity
-
(Required) Activity object.
Return
(string)
Source
File: bp-blogs/bp-blogs-activity.php
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 | function bp_blogs_activity_comment_single_action( $retval , $activity ) { if ( 'activity_comment' !== $activity ->type ) { return $retval ; } if ( bp_disable_blogforum_comments() ) { return $retval ; } $parent_activity = new BP_Activity_Activity( $activity ->item_id ); if ( ! isset( $parent_activity ->type ) ) { return $retval ; } $post_type = bp_activity_post_type_get_tracking_arg( $parent_activity ->type, 'post_type' ); if ( ! $post_type ) { return $retval ; } $blog_comment_id = bp_activity_get_meta( $activity ->id, "bp_blogs_{$post_type}_comment_id" ); if ( ! empty ( $blog_comment_id ) ) { $bp = buddypress(); // Check if a comment action id is set for the parent activity $comment_action_id = bp_activity_post_type_get_tracking_arg( $parent_activity ->type, 'comment_action_id' ); // Use the action string callback for the activity type if ( ! empty ( $comment_action_id ) ) { // Fake a 'new_{post_type}_comment' by cloning the activity object. $object = clone $activity ; // Set the type of the activity to be a comment about a post type $object ->type = $comment_action_id ; // Use the blog ID as the item_id. $object ->item_id = $parent_activity ->item_id; // Use comment ID as the secondary_item_id. $object ->secondary_item_id = $blog_comment_id ; // Get the format callback for this activity comment $format_callback = bp_activity_post_type_get_tracking_arg( $comment_action_id , 'format_callback' ); // now format the activity action using the 'new_{post_type}_comment' action callback if ( is_callable ( $format_callback ) ) { $retval = call_user_func_array( $format_callback , array ( '' , $object ) ); } } } return $retval ; } |
Changelog
Version | Description |
---|---|
BuddyPress 2.0.1 | 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.