_clear_modified_cache_on_transition_comment_status

Clear the lastcommentmodified cached value when a comment status is changed.

Description

_clear_modified_cache_on_transition_comment_status( (string) $new_status, (string) $old_status ); 

Deletes the lastcommentmodified cache key when a comment enters or leaves 'approved' status.

Parameters (2)

0. $new_status (string)
The new comment status.
1. $old_status (string)
The old comment status.

Usage

  1. if ( !function_exists( '_clear_modified_cache_on_transition_comment_status' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // The new comment status. 
  5. $new_status = ''; 
  6.  
  7. // The old comment status. 
  8. $old_status = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _clear_modified_cache_on_transition_comment_status($new_status, $old_status); 
  12.  

Defined (1)

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

/wp-includes/comment.php  
  1. function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) { 
  2. if ( 'approved' === $new_status || 'approved' === $old_status ) { 
  3. foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) { 
  4. wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );