<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][10542] trunk/src/bp-activity: Post Type Activities: allow post types to register comments tracking</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="http://buddypress.trac.wordpress.org/changeset/10542">10542</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"http://buddypress.trac.wordpress.org/changeset/10542","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>imath</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2016-02-07 16:29:52 +0000 (Sun, 07 Feb 2016)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Post Type Activities: allow post types to register comments tracking

When registering a post type, it is now possible to inform BuddyPress the comments about this post type need to be tracked into the activity stream. This can be achieved by making sure the post type supports "comments" and "buddypress-activity" and by adding extra parameters to the "bp_activity" argument of the `register_post_type()` function one or by using the `bp_activity_set_post_type_tracking_args()` function.

We are also introducing a new function to inform if an activity type is supporting a specific feature: `bp_activity_type_supports()`. For now this function is helping to check if:
- a activity supports a an activity comment
- an activity comment supports synchronization with a post type comment

Props shanebp, r-a-y.

See <a href="http://buddypress.trac.wordpress.org/ticket/6482">#6482</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpactivitybpactivityfunctionsphp">trunk/src/bp-activity/bp-activity-functions.php</a></li>
<li><a href="#trunksrcbpactivitybpactivitytemplatephp">trunk/src/bp-activity/bp-activity-template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpactivitybpactivityfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-functions.php   2016-02-07 12:01:24 UTC (rev 10541)
+++ trunk/src/bp-activity/bp-activity-functions.php     2016-02-07 16:29:52 UTC (rev 10542)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -438,8 +438,21 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return false;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        $activity_labels = array(
+               /* Post labels */
+               'bp_activity_admin_filter',
+               'bp_activity_front_filter',
+               'bp_activity_new_post',
+               'bp_activity_new_post_ms',
+               /* Comment labels */
+               'bp_activity_comments_admin_filter',
+               'bp_activity_comments_front_filter',
+               'bp_activity_new_comment',
+               'bp_activity_new_comment_ms'
+       );
+
</ins><span class="cx" style="display: block; padding: 0 10px">         // Labels are loaded into the post type object.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        foreach ( array( 'bp_activity_admin_filter', 'bp_activity_front_filter', 'bp_activity_new_post', 'bp_activity_new_post_ms' ) as $label_type ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $activity_labels as $label_type ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( ! empty( $args[ $label_type ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $wp_post_types[ $post_type ]->labels->{$label_type} = $args[ $label_type ];
</span><span class="cx" style="display: block; padding: 0 10px">                        unset( $args[ $label_type ] );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -456,6 +469,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Get tracking arguments for a specific post type.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0 Add post type comments tracking args
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @param  string $post_type Name of the post type.
</span><span class="cx" style="display: block; padding: 0 10px">  * @return object The tracking arguments of the post type.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -465,17 +479,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">                return false;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $post_type_object = get_post_type_object( $post_type );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type_object           = get_post_type_object( $post_type );
+       $post_type_support_comments = post_type_supports( $post_type, 'comments' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $post_type_activity = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                'component_id'      => buddypress()->activity->id,
-               'action_id'         => 'new_' . $post_type,
-               'format_callback'   => 'bp_activity_format_activity_action_custom_post_type_post',
-               'front_filter'      => $post_type_object->labels->name,
-               'contexts'          => array( 'activity' ),
-               'position'          => 0,
-               'singular'          => strtolower( $post_type_object->labels->singular_name ),
-               'activity_comment' => ! post_type_supports( $post_type, 'comments' ),
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         'component_id'            => buddypress()->activity->id,
+               'action_id'               => 'new_' . $post_type,
+               'format_callback'         => 'bp_activity_format_activity_action_custom_post_type_post',
+               'front_filter'            => $post_type_object->labels->name,
+               'contexts'                => array( 'activity' ),
+               'position'                => 0,
+               'singular'                => strtolower( $post_type_object->labels->singular_name ),
+               'activity_comment'        => ! $post_type_support_comments,
+               'comment_action_id'       => false,
+               'comment_format_callback' => 'bp_activity_format_activity_action_custom_post_type_comment',
</ins><span class="cx" style="display: block; padding: 0 10px">         );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( ! empty( $post_type_object->bp_activity ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -508,6 +525,52 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $post_type_activity->new_post_type_action_ms = $post_type_object->labels->bp_activity_new_post_ms;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        // If the post type supports comments and has a comment action id, build the comments tracking args
+       if ( $post_type_support_comments && ! empty( $post_type_activity->comment_action_id ) ) {
+               // Init a new container for the activity type for comments
+               $post_type_activity->comments_tracking = new stdClass();
+
+               // Build the activity type for comments
+               $post_type_activity->comments_tracking->component_id = $post_type_activity->component_id;
+               $post_type_activity->comments_tracking->action_id    = $post_type_activity->comment_action_id;
+
+               // Try to get the comments admin filter from the post type labels.
+               if ( ! empty( $post_type_object->labels->bp_activity_comments_admin_filter ) ) {
+                       $post_type_activity->comments_tracking->admin_filter = $post_type_object->labels->bp_activity_comments_admin_filter;
+
+               // Fall back to a generic name.
+               } else {
+                       $post_type_activity->comments_tracking->admin_filter = _x( 'New item comment posted', 'Post Type generic comments activity admin filter', 'buddypress' );
+               }
+
+               $post_type_activity->comments_tracking->format_callback = $post_type_activity->comment_format_callback;
+
+               // Check for the comments front filter in the post type labels.
+               if ( ! empty( $post_type_object->labels->bp_activity_comments_front_filter ) ) {
+                       $post_type_activity->comments_tracking->front_filter = $post_type_object->labels->bp_activity_comments_front_filter;
+
+               // Fall back to a generic name.
+               } else {
+                       $post_type_activity->comments_tracking->front_filter = sprintf( __( '%s comments', 'buddypress' ), $post_type_object->labels->singular_name );
+               }
+
+               $post_type_activity->comments_tracking->contexts = $post_type_activity->contexts;
+               $post_type_activity->comments_tracking->position = (int) $post_type_activity->position + 1;
+
+               // Try to get the action for new post type comment action on non-multisite installations.
+               if ( ! empty( $post_type_object->labels->bp_activity_new_comment ) ) {
+                       $post_type_activity->comments_tracking->new_post_type_comment_action = $post_type_object->labels->bp_activity_new_comment;
+               }
+
+               // Try to get the action for new post type comment action on multisite installations.
+               if ( ! empty( $post_type_object->labels->bp_activity_new_comment_ms ) ) {
+                       $post_type_activity->comments_tracking->new_post_type_comment_action_ms = $post_type_object->labels->bp_activity_new_comment_ms;
+               }
+       }
+
+       // Finally make sure we'll be able to find the post type this activity type is associated to.
+       $post_type_activity->post_type = $post_type;
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters tracking arguments for a specific post type.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -523,6 +586,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * Get tracking arguments for all post types.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.2.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0 Include post type comments tracking args if needed
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @return array List of post types with their tracking arguments.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -536,6 +600,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $track_post_type = bp_activity_get_post_type_tracking_args( $post_type );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                if ( ! empty( $track_post_type ) ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        // Set the post type comments tracking args
+                       if ( ! empty( $track_post_type->comments_tracking->action_id ) ) {
+                               // Used to check support for comment tracking by activity type (new_post_type_comment)
+                               $track_post_type->comments_tracking->comments_tracking = true;
+
+                               // Used to be able to find the post type this activity type is associated to.
+                               $track_post_type->comments_tracking->post_type = $post_type;
+
+                               $post_types_tracking_args[ $track_post_type->comments_tracking->action_id ] = $track_post_type->comments_tracking;
+
+                               // Used to check support for comment tracking by activity type (new_post_type)
+                               $track_post_type->comments_tracking = true;
+                       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">                         $post_types_tracking_args[ $track_post_type->action_id ] = $track_post_type;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -553,6 +631,117 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Check if the *Post Type* activity supports a specific feature.
+ *
+ * @since 2.5.0
+ *
+ * @param  string $activity_type The activity type to check.
+ * @param  string $feature       The feature to check. Currently supports:
+ *                               'post-type-comment-tracking', 'post-type-comment-reply' & 'comment-reply'.
+ *                               See inline doc for more info.
+ * @return bool
+ */
+function bp_activity_type_supports( $activity_type = '', $feature = '' ) {
+       $retval = false;
+
+       $bp = buddypress();
+
+       switch ( $feature ) {
+               /**
+                * Does this activity type support comment tracking?
+                *
+                * eg. 'new_blog_post' and 'new_blog_comment' will both return true.
+                */
+               case 'post-type-comment-tracking' :
+                       // Set the activity track global if not set yet
+                       if ( empty( $bp->activity->track ) ) {
+                               $bp->activity->track = bp_activity_get_post_types_tracking_args();
+                       }
+
+                       if ( ! empty( $bp->activity->track[ $activity_type ]->comments_tracking ) ) {
+                               $retval = true;
+                       }
+                       break;
+
+               /**
+                * Is this a parent activity type that support post comments?
+                *
+                * eg. 'new_blog_post' will return true; 'new_blog_comment' will return false.
+                */
+               case 'post-type-comment-reply' :
+                       // Set the activity track global if not set yet.
+                       if ( empty( $bp->activity->track ) ) {
+                               $bp->activity->track = bp_activity_get_post_types_tracking_args();
+                       }
+
+                       if ( ! empty( $bp->activity->track[ $activity_type ]->comments_tracking ) && ! empty( $bp->activity->track[ $activity_type ]->comment_action_id ) ) {
+                               $retval = true;
+                       }
+                       break;
+
+               /**
+                * Does this activity type support comment & reply?
+                */
+               case 'comment-reply' :
+                       // Set the activity track global if not set yet.
+                       if ( empty( $bp->activity->track ) ) {
+                               $bp->activity->track = bp_activity_get_post_types_tracking_args();
+                       }
+
+                       // Post Type activities
+                       if ( ! empty( $bp->activity->track[ $activity_type ] ) ) {
+                               if ( isset( $bp->activity->track[ $activity_type ]->activity_comment ) ) {
+                                       $retval = $bp->activity->track[ $activity_type ]->activity_comment;
+                               }
+
+                               // Eventually override with comment synchronization feature.
+                               if ( isset( $bp->activity->track[ $activity_type ]->comments_tracking ) ) {
+                                       $retval = $bp->activity->track[ $activity_type ]->comments_tracking && ! bp_disable_blogforum_comments();
+                               }
+
+                       // Retired Forums component
+                       } elseif ( 'new_forum_topic' === $activity_type || 'new_forum_post' === $activity_type ) {
+                               $retval = ! bp_disable_blogforum_comments();
+
+                       // By Default, all other activity types are supporting comments.
+                       } else {
+                               $retval = true;
+                       }
+                       break;
+       }
+
+       return $retval;
+}
+
+/**
+ * Get a specific tracking argument for a given activity type
+ *
+ * @since 2.5.0
+ *
+ * @param  string       $activity_type the activity type.
+ * @param  string       $arg           the key of the tracking argument.
+ * @return mixed        the value of the tracking arg, false if not found.
+ */
+function bp_activity_post_type_get_tracking_arg( $activity_type, $arg = '' ) {
+       if ( empty( $activity_type ) || empty( $arg ) ) {
+               return false;
+       }
+
+       $bp = buddypress();
+
+       // Set the activity track global if not set yet
+       if ( empty( $bp->activity->track ) ) {
+               $bp->activity->track = bp_activity_get_post_types_tracking_args();
+       }
+
+       if ( isset( $bp->activity->track[ $activity_type ]->{$arg} ) ) {
+               return $bp->activity->track[ $activity_type ]->{$arg};
+       } else {
+               return false;
+       }
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Get all components' activity actions, sorted by their position attribute.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 2.2.0
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1403,6 +1592,57 @@
</span><span class="cx" style="display: block; padding: 0 10px">        return apply_filters( 'bp_activity_custom_post_type_post_action', $action, $activity );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/**
+ * Format activity action strings for custom post types comments.
+ *
+ * @since 2.5.0
+ *
+ * @param string $action   Static activity action.
+ * @param object $activity Activity data object.
+ *
+ * @return string
+ */
+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 );
+
+       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 {
+                       $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 );
+               }
+       } 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 {
+                       $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 );
+               }
+       }
+
+       /**
+        * 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 );
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px">  * Business functions are where all the magic happens in BuddyPress. They will
</span><span class="cx" style="display: block; padding: 0 10px">  * handle the actual saving or manipulation of information. Usually they will
</span></span></pre></div>
<a id="trunksrcbpactivitybpactivitytemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/bp-activity/bp-activity-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/bp-activity/bp-activity-template.php    2016-02-07 12:01:24 UTC (rev 10541)
+++ trunk/src/bp-activity/bp-activity-template.php      2016-02-07 16:29:52 UTC (rev 10542)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3029,48 +3029,27 @@
</span><span class="cx" style="display: block; padding: 0 10px">        global $activities_template;
</span><span class="cx" style="display: block; padding: 0 10px">        $bp = buddypress();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Assume activity can be commented on.
-       $can_comment = true;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Determine ability to comment based on activity type name.
+       $activity_type = bp_get_activity_type();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        // Determine ability to comment based on activity action name.
-       $activity_action = bp_get_activity_action_name();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Get the 'comment-reply' support for the current activity type.
+       $can_comment = bp_activity_type_supports( $activity_type, 'comment-reply' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $turn_off = 0;
-       if ( ! empty( $activities_template->disable_blogforum_replies ) ) {
-               $turn_off = 1;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Neutralize activity_comment.
+       if ( 'activity_comment' === $activity_type ) {
+               $can_comment = false;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $maybe_turn_off = array_fill_keys( array(
-               'new_blog_post',
-               'new_blog_comment',
-               'new_forum_topic',
-               'new_forum_post',
-       ), $turn_off );
-
-       $maybe_turn_off['activity_comment'] = 1;
-
-       // Fetch all the tracked post types once.
-       if ( empty( $bp->activity->track ) ) {
-               $bp->activity->track = bp_activity_get_post_types_tracking_args();
-       }
-
-       foreach ( $bp->activity->track as $action => $tracking_args ) {
-               if ( empty( $tracking_args->activity_comment ) ) {
-                       $maybe_turn_off[ $action ] = $turn_off;
-               }
-       }
-
-       $can_comment = empty( $maybe_turn_off[ $activity_action ] );
-
</del><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Filters whether a comment can be made on an activity item.
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @since 1.5.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * @since 2.5.0 Use $activity_type instead of $activity_name for the second parameter.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><span class="cx" style="display: block; padding: 0 10px">         * @param bool   $can_comment     Status on if activity can be commented on.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param string $activity_action Current activity action being checked on.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param string $activity_type   Current activity type being checked on.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_action );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ return apply_filters( 'bp_activity_can_comment', $can_comment, $activity_type );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre>
</div>
</div>

</body>
</html>