bp_blogs_disable_activity_commenting

Disable activity commenting for blog posts based on certain criteria.

Description

bp_blogs_disable_activity_commenting( (bool) $retval ); 

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 - the activity entry is a new_blog_comment type

Parameters (1)

0. $retval (bool)
Is activity commenting enabled for this activity entry.

Usage

  1. if ( !function_exists( 'bp_blogs_disable_activity_commenting' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-activity.php'; 
  3.  
  4. // Is activity commenting enabled for this activity entry. 
  5. $retval = true; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_blogs_disable_activity_commenting($retval); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-blogs/bp-blogs-activity.php  
  1. function bp_blogs_disable_activity_commenting( $retval ) { 
  2. global $activities_template; 
  3.  
  4. // If activity commenting is disabled, return current value. 
  5. if ( bp_disable_blogforum_comments() || ! isset( $activities_template->in_the_loop ) ) { 
  6. return $retval; 
  7.  
  8. $type = bp_get_activity_type(); 
  9.  
  10. // It's a post type supporting comment tracking. 
  11. if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) { 
  12. // The activity type is supporting comments or replies 
  13. if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) { 
  14. // Setup some globals we'll need to reference later. 
  15. bp_blogs_setup_activity_loop_globals( $activities_template->activity ); 
  16.  
  17. // If comments are closed for the WP blog post, we should disable 
  18. // activity comments for this activity entry. 
  19. if ( empty(buddypress)->blogs->allow_comments[ bp_get_activity_id() ] ) ) { 
  20. $retval = false; 
  21. // The activity type does not support comments or replies 
  22. } else { 
  23. $retval = false; 
  24.  
  25. return $retval;