_prime_comment_caches

函式
_prime_comment_caches ( $comment_ids, $update_meta_cache = true )
引數
  • (int[]) $comment_ids Array of comment IDs.
    Required:
  • (bool) $update_meta_cache Optional. Whether to update the meta cache. Default true.
    Required:
    Default: true
相關
  • update_comment_cache()
定義位置
相關方法
_prime_post_cachesupdate_comment_cache_prime_site_caches_prime_term_caches_prime_network_caches
引入
4.4.0
棄用
-

prime_comment_caches: 這個函式是用來給評論的快取打底的。它預先載入評論ID列表的評論資料,以提高以後請求評論時的效能。

將任何來自給定ID的評論新增到快取中,這些評論在快取中並不存在。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) {
global $wpdb;
$non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' );
if ( ! empty( $non_cached_ids ) ) {
$fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );
update_comment_cache( $fresh_comments, $update_meta_cache );
}
}
function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' ); if ( ! empty( $non_cached_ids ) ) { $fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); update_comment_cache( $fresh_comments, $update_meta_cache ); } }
function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $comment_ids, 'comment' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_comments = $wpdb->get_results( sprintf( "SELECT $wpdb->comments.* FROM $wpdb->comments WHERE comment_ID IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );

		update_comment_cache( $fresh_comments, $update_meta_cache );
	}
}

常見問題

FAQs
檢視更多 >