bbp_force_comment_status

Force comments_status to 'closed' for bbPress post types.

Description

bbp_force_comment_status( (bool) $open, (int) $post_id = 0 ); 

Parameters (2)

0. $open (bool)
True if open, false if closed
1. $post_id — Optional. (int)
ID of the post to check

Usage

  1. if ( !function_exists( 'bbp_force_comment_status' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'bbpress/includes/core/theme-compat.php'; 
  3.  
  4. // True if open, false if closed 
  5. $open = true; 
  6.  
  7. // ID of the post to check 
  8. $post_id = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bbp_force_comment_status($open, $post_id); 
  12.  

Defined (1)

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

/includes/core/theme-compat.php  
  1. function bbp_force_comment_status( $open, $post_id = 0 ) { 
  2.  
  3. // Get the post type of the post ID 
  4. $post_type = get_post_type( $post_id ); 
  5.  
  6. // Default return value is what is passed in $open 
  7. $retval = $open; 
  8.  
  9. // Only force for bbPress post types 
  10. switch ( $post_type ) { 
  11. $retval = false; 
  12. break; 
  13.  
  14. // Allow override of the override 
  15. return apply_filters( 'bbp_force_comment_status', $retval, $open, $post_id, $post_type );