/** * Checks if an activity item can be replied to. * * This method merges functionality from {@link bp_activity_can_comment()} and * {@link bp_blogs_disable_activity_commenting()}. This is done because the activity * list table doesn't use a BuddyPress activity loop, which prevents those * functions from working as intended. * * @since BuddyPress (2.0.0) * * @param array $item An array version of the BP_Activity_Activity object. * * @return bool */ protected function can_comment($item) { $can_comment = true; if ($this->disable_blogforum_comments) { switch ($item['type']) { case 'new_blog_post': case 'new_blog_comment': case 'new_forum_topic': case 'new_forum_post': $can_comment = false; break; } // activity comments supported } else { // activity comment if ('activity_comment' == $item['type']) { // blogs if (bp_is_active('blogs')) { // grab the parent activity entry $parent_activity = new BP_Activity_Activity($item['item_id']); // fetch blog post comment depth and if the blog post's comments are open bp_blogs_setup_activity_loop_globals($parent_activity); // check if the activity item can be replied to if (false === bp_blogs_can_comment_reply(true, $item)) { $can_comment = false; } } // blog post } elseif ('new_blog_post' == $item['type']) { if (bp_is_active('blogs')) { bp_blogs_setup_activity_loop_globals((object) $item); if (empty(buddypress()->blogs->allow_comments[$item['id']])) { $can_comment = false; } } } } /** * Filters if an activity item can be commented on or not. * * @since BuddyPress (2.0.0) * * @param bool $can_comment Whether an activity item can be commented on or not. */ return apply_filters('bp_activity_list_table_can_comment', $can_comment); }
/** * Checks if an activity item can be replied to. * * This method merges functionality from {@link bp_activity_can_comment()} and * {@link bp_blogs_disable_activity_commenting()}. This is done because the activity * list table doesn't use a BuddyPress activity loop, which prevents those * functions from working as intended. * * @since 2.0.0 * @since 2.5.0 Include Post type activities types * * @param array $item An array version of the BP_Activity_Activity object. * @return bool $can_comment */ protected function can_comment($item) { $can_comment = bp_activity_type_supports($item['type'], 'comment-reply'); if (!$this->disable_blogforum_comments && bp_is_active('blogs')) { $parent_activity = false; if (bp_activity_type_supports($item['type'], 'post-type-comment-tracking')) { $parent_activity = (object) $item; } elseif ('activity_comment' === $item['type']) { $parent_activity = new BP_Activity_Activity($item['item_id']); } if (isset($parent_activity->type) && bp_activity_post_type_get_tracking_arg($parent_activity->type, 'post_type')) { // Fetch blog post comment depth and if the blog post's comments are open. bp_blogs_setup_activity_loop_globals($parent_activity); $can_comment = bp_blogs_can_comment_reply(true, $item); } } /** * Filters if an activity item can be commented on or not. * * @since 2.0.0 * @since 2.5.0 Add a second parameter to include the activity item into the filter. * * @param bool $can_comment Whether an activity item can be commented on or not. * @param array $item An array version of the BP_Activity_Activity object. */ return apply_filters('bp_activity_list_table_can_comment', $can_comment, $item); }