Comments: Fire an action after a comment is removed from object cache.
When a comment is removed from the object cache, the `clean_comment_cache` action is now fired. This provides plugin and theme developers a chance to perform secondary cache invalidation as needed. Props spacedmonkey. Fixes #35610. git-svn-id: https://develop.svn.wordpress.org/trunk@36405 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
746f545f9a
commit
01f88b1ae4
|
@ -2516,15 +2516,24 @@ function xmlrpc_pingback_error( $ixr_error ) {
|
|||
//
|
||||
|
||||
/**
|
||||
* Removes comment ID from the comment cache.
|
||||
* Removes a comment from the object cache.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*
|
||||
* @param int|array $ids Comment ID or array of comment IDs to remove from cache
|
||||
* @param int|array $ids Comment ID or an array of comment IDs to remove from cache.
|
||||
*/
|
||||
function clean_comment_cache($ids) {
|
||||
foreach ( (array) $ids as $id ) {
|
||||
wp_cache_delete( $id, 'comment' );
|
||||
|
||||
/**
|
||||
* Fires after a comment has been removed from the object cache.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param int $id Comment ID.
|
||||
*/
|
||||
do_action( 'clean_comment_cache', $id );
|
||||
}
|
||||
|
||||
wp_cache_set( 'last_changed', microtime(), 'comment' );
|
||||
|
|
Loading…
Reference in New Issue