wp_defer_comment_counting

Whether to defer comment counting.

Description

wp_defer_comment_counting( (constant) $defer = null ); 

When setting $defer to true, all post comment counts will not be updated until $defer is set to false. When $defer is set to false, then all previously deferred updated post comment counts will then be automatically updated without having to call wp_update_comment_count() after.

Parameters (1)

0. $defer — Optional. (constant) => null
The defer.

Usage

  1. if ( !function_exists( 'wp_defer_comment_counting' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // The defer. 
  5. $defer = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_defer_comment_counting($defer); 
  9.  

Defined (1)

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

/wp-includes/comment.php  
  1. function wp_defer_comment_counting($defer=null) { 
  2. static $_defer = false; 
  3.  
  4. if ( is_bool($defer) ) { 
  5. $_defer = $defer; 
  6. // flush any deferred counts 
  7. if ( !$defer ) 
  8. wp_update_comment_count( null, true ); 
  9.  
  10. return $_defer;