bp_activity_feed_item_description(); ?> <?php if (bp_activity_can_comment()) { ?> <p><?php printf(__('Comments: %s', 'buddypress'), bp_activity_get_comment_count()); ?> </p> <?php } ?> <?php if ('activity_comment' == bp_get_activity_action_name()) { ?> <br /><strong><?php _e('In reply to', 'buddypress'); ?> </strong> - <?php bp_activity_parent_content(); ?> <?php } ?> ]]> </description> <?php
/** * Disable activity commenting for blog posts based on certain criteria. * * If activity commenting is enabled for blog posts, we still need to disable * commenting if: * - comments are disabled for the WP blog post from the admin dashboard * - the WP blog post is supposed to be automatically closed from comments * based on a certain age * - the activity entry is a 'new_blog_comment' type * * @since BuddyPress (2.0.0) * * @param bool $retval Is activity commenting enabled for this activity entry? * @return bool */ function bp_blogs_disable_activity_commenting( $retval ) { // if activity commenting is disabled, return current value if ( bp_disable_blogforum_comments() ) { return $retval; } // activity commenting is enabled for blog posts switch ( bp_get_activity_action_name() ) { // we still have to disable activity commenting for 'new_blog_comment' items // commenting should only be done on the parent 'new_blog_post' item case 'new_blog_comment' : $retval = false; break; // check if commenting is disabled for the WP blog post // we should extrapolate this and automate this for plugins... or not case 'new_blog_post' : global $activities_template; // setup some globals we'll need to reference later bp_blogs_setup_activity_loop_globals( $activities_template->activity ); // if comments are closed for the WP blog post, we should disable // activity comments for this activity entry if ( empty( buddypress()->blogs->allow_comments[bp_get_activity_id()] ) ) { $retval = false; } break; } return $retval; }
/** * Maybe disable activity stream comments on select actions * * @since bbPress (r3399) * @global BP_Activity_Template $activities_template * @param boolean $can_comment * @uses bp_get_activity_action_name() * @return boolean */ public function activity_can_comment($can_comment = true) { global $activities_template; // Already forced off, so comply if (false === $can_comment) { return $can_comment; } // Check if blog & forum activity stream commenting is off if (false === $activities_template->disable_blogforum_replies || (int) $activities_template->disable_blogforum_replies) { // Get the current action name $action_name = bp_get_activity_action_name(); // Setup the array of possibly disabled actions $disabled_actions = array($this->topic_create, $this->reply_create); // Check if this activity stream action is disabled if (in_array($action_name, $disabled_actions)) { $can_comment = false; } } return $can_comment; }
/** * Output the feed's item content. */ protected function feed_content() { bp_activity_content_body(); switch ($this->id) { // Also output parent activity item if we're on a specific feed. case 'favorites': case 'friends': case 'mentions': case 'personal': if ('activity_comment' == bp_get_activity_action_name()) { ?> <strong><?php _e('In reply to', 'buddypress'); ?> </strong> - <?php bp_activity_parent_content(); ?> <?php } break; } }
/** * Repsect disable_blogforum_replies * * BuddyPress allows you to disable activity commenting on items related to blog posts or * to forums, content types that have their own reply/comment mechanisms. Since BuddyPress * Docs are similar in this respect, they should respect this setting as well. * * In the future, I may add a separate toggle for this. I may also build a filter that * redirects the Comment/Reply link so that it goes to the Doc's Comment section, or so that * this setting reflects the individual Doc's can_comment settings. (For now, this would * require too many additional queries.) * * This function filters bp_activity_can_comment, which was introduced in BP 1.5. It is * therefore not backward compatible with BP < 1.5. * * @package BuddyPress_Docs * @since 1.1.17 * * @param bool $can_comment Whether the current user can comment. Comes from * bp_activity_can_comment() * @return bool $can_comment */ function activity_can_comment($can_comment) { global $activities_template; if ('bp_doc_created' == bp_get_activity_action_name() || 'bp_doc_edited' == bp_get_activity_action_name() || 'bp_doc_comment' == bp_get_activity_action_name()) { // Flip the 'disable' $can_comment = !(bool) $activities_template->disable_blogforum_replies; } return apply_filters('bp_docs_activity_can_comment', $can_comment); }
/** * Determine if a comment can be made on an activity item * * @since 1.2.0 * * @global object $activities_template {@link BP_Activity_Template} * @global object $bp BuddyPress global settings * @uses bp_get_activity_action_name() * @uses apply_filters() To call the 'bp_activity_can_comment' hook * * @return bool $can_comment Defaults to true */ function bp_activity_can_comment() { global $activities_template, $bp; $can_comment = true; if (false === $activities_template->disable_blogforum_replies || (int) $activities_template->disable_blogforum_replies) { if ('new_blog_post' == bp_get_activity_action_name() || 'new_blog_comment' == bp_get_activity_action_name() || 'new_forum_topic' == bp_get_activity_action_name() || 'new_forum_post' == bp_get_activity_action_name()) { $can_comment = false; } } if ('activity_comment' == bp_get_activity_action_name()) { $can_comment = false; } return apply_filters('bp_activity_can_comment', $can_comment); }
/** * Determine if a comment can be made on an activity item. * * @since BuddyPress (1.2.0) * * @global object $activities_template {@link BP_Activity_Template} * @uses bp_get_activity_action_name() * @uses apply_filters() To call the 'bp_activity_can_comment' hook. * * @return bool $can_comment True if item can receive comments. */ function bp_activity_can_comment() { global $activities_template; $bp = buddypress(); // Assume activity can be commented on $can_comment = true; // Determine ability to comment based on activity action name $activity_action = bp_get_activity_action_name(); $turn_off = 0; if (!empty($activities_template->disable_blogforum_replies)) { $turn_off = 1; } $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]); /** * Filters whether a comment can be made on an activity item. * * @since BuddyPress (1.5.0) * * @param bool $can_comment Status on if activity can be commented on. * @param string $activity_action Current activity action being checked on. */ return apply_filters('bp_activity_can_comment', $can_comment, $activity_action); }
/** * Determine if a comment can be made on an activity item. * * @since BuddyPress (1.2) * * @global object $activities_template {@link BP_Activity_Template} * @uses bp_get_activity_action_name() * @uses apply_filters() To call the 'bp_activity_can_comment' hook. * * @return bool $can_comment True if item can receive comments. */ function bp_activity_can_comment() { global $activities_template; // Assume activity can be commented on $can_comment = true; // Determine ability to comment based on activity action name $activity_action = bp_get_activity_action_name(); switch ($activity_action) { // Maybe turn off for blog and forum updates case 'new_blog_post': case 'new_blog_comment': case 'new_forum_topic': case 'new_forum_post': if (!empty($activities_template->disable_blogforum_replies)) { $can_comment = false; } break; // Turn off for activity comments // Turn off for activity comments case 'activity_comment': $can_comment = false; break; } return apply_filters('bp_activity_can_comment', $can_comment, $activity_action); }
function bp_activity_can_comment() { global $activities_template, $bp; if ( false === $activities_template->disable_blogforum_replies || (int)$activities_template->disable_blogforum_replies ) { if ( 'new_blog_post' == bp_get_activity_action_name() || 'new_blog_comment' == bp_get_activity_action_name() || 'new_forum_topic' == bp_get_activity_action_name() || 'new_forum_post' == bp_get_activity_action_name() ) return false; } if ( 'activity_comment' == bp_get_activity_action_name() ) return false; return true; }