
如何开启Debug记录WordPress日志文件
update_comment_cache ( $comments, $update_meta_cache = true )
update_comment_cache: 这个函数更新当前站点的评论数据缓存。每当一个评论被创建、更新或删除时,它就被调用。
更新给定评论的缓存。
将把$comments中的评论添加到缓存中。如果评论ID已经存在于评论缓存中,那么它将不会被更新。评论被添加到缓存中,使用评论组,关键是使用评论的ID。
function update_comment_cache( $comments, $update_meta_cache = true ) { $data = array(); foreach ( (array) $comments as $comment ) { $data[ $comment->comment_ID ] = $comment; } wp_cache_add_multiple( $data, 'comment' ); if ( $update_meta_cache ) { // Avoid `wp_list_pluck()` in case `$comments` is passed by reference. $comment_ids = array(); foreach ( $comments as $comment ) { $comment_ids[] = $comment->comment_ID; } update_meta_cache( 'comment', $comment_ids ); } }