/** * Check if an activity comment associated with a blog post can be replied to. * * By default, disables replying to activity comments if the corresponding WP * blog post no longer accepts comments. * * This check uses a locally-cached value set in {@link bp_blogs_disable_activity_commenting()} * via {@link bp_blogs_setup_activity_loop_globals()}. * * @since 2.0.0 * * @param bool $retval Are replies allowed for this activity reply. * @param object|array $comment The activity comment object. * * @return bool */ function bp_blogs_can_comment_reply($retval, $comment) { if (is_array($comment)) { $comment = (object) $comment; } // Check comment depth and disable if depth is too large. if (isset(buddypress()->blogs->thread_depth[$comment->item_id])) { if (bp_activity_get_comment_depth() > buddypress()->blogs->thread_depth[$comment->item_id]) { $retval = false; } } // Check if we should disable activity replies based on the parent activity. if (isset(buddypress()->blogs->allow_comments[$comment->item_id])) { // The blog post has closed off commenting, so we should disable all activity // comments under the parent 'new_blog_post' activity entry. if (empty(buddypress()->blogs->allow_comments[$comment->item_id])) { $retval = false; } } return $retval; }
/** * Determine whether a comment can be made on an activity reply item. * * @since BuddyPress (1.5.0) * * @param object $comment Activity comment. * @return bool $can_comment True if comment can receive comments, otherwise * false. */ function bp_activity_can_comment_reply($comment = '') { // Assume activity can be commented on $can_comment = true; // Check that comment exists if (empty($comment)) { $comment = bp_activity_current_comment(); } if (!empty($comment)) { // Fall back on current comment in activity loop $comment_depth = isset($comment->depth) ? intval($comment->depth) : bp_activity_get_comment_depth(); // Threading is turned on, so check the depth if (get_option('thread_comments')) { $can_comment = (bool) ($comment_depth < get_option('thread_comments_depth')); // No threading for comment replies if no threading for comments } else { $can_comment = false; } } return (bool) apply_filters('bp_activity_can_comment_reply', $can_comment, $comment); }
/** * Determine whether a comment can be made on an activity reply item. * * @since BuddyPress (1.5.0) * * @param object $comment Activity comment. * @return bool $can_comment True if comment can receive comments, otherwise * false. */ function bp_activity_can_comment_reply($comment = '') { // Assume activity can be commented on $can_comment = true; // Check that comment exists if (empty($comment)) { $comment = bp_activity_current_comment(); } if (!empty($comment)) { // Fall back on current comment in activity loop $comment_depth = isset($comment->depth) ? intval($comment->depth) : bp_activity_get_comment_depth(); // Threading is turned on, so check the depth if (get_option('thread_comments')) { $can_comment = (bool) ($comment_depth < get_option('thread_comments_depth')); // No threading for comment replies if no threading for comments } else { $can_comment = false; } } /** * Filters whether a comment can be made on an activity reply item. * * @since BuddyPress (1.5.0) * * @param bool $can_comment Status on if activity reply can be commented on. * @param string $comment Current comment being checked on. */ return (bool) apply_filters('bp_activity_can_comment_reply', $can_comment, $comment); }
/** * Determine if a comment can be made on an activity reply item. * * Defaults to true, but can be modified by plugins. * * @since BuddyPress (1.5) * * @uses apply_filters() To call the 'bp_activity_can_comment_reply' hook * * @param object $comment Activity comment. * @return bool $can_comment True if comment can receive comments. */ function bp_activity_can_comment_reply($comment) { $can_comment = true; if (get_option('thread_comments') && bp_activity_get_comment_depth() >= get_option('thread_comments_depth')) { $can_comment = false; } return apply_filters('bp_activity_can_comment_reply', $can_comment, $comment); }