wpseek.com
WordPress开发者和主题制作者的搜索引擎
update_comment_cache › WordPress Function
Since2.3.0
已弃用n/a
› update_comment_cache ( $comments, $update_meta_cache = true )
参数: (2) |
|
定义在: |
|
文档: | |
Change Log: |
|
Updates the comment cache of given comments.
Will add the comments in $comments to the cache. If comment ID already exists in the comment cache then it will not be updated. The comment is added to the cache using the comment group with the key using the ID of the comments.Related Functions: update_meta_cache, update_postmeta_cache, update_termmeta_cache, update_comment_meta, update_post_cache
源码
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 ); } }