функция since 4.4.0

update_comment_cache()

Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.

Сигнатура

update_comment_cache( WP_Comment[] $comments, bool $update_meta_cache = true )

Описание

Добавляет комментарии из $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.

Параметры

$comments WP_Comment[] обязательный
Массив объектов комментариев
$update_meta_cache bool необязательный = true
Следует ли обновлять кэш commentmeta.

Исходный код

wp-includes/comment.php:3444

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 );
	}
}

История изменений

ВерсияОписание
4.4.0 Introduced the $update_meta_cache parameter.
2.3.0 Introduced.

Что будем искать? Например,Продвижение

Этот сайт использует куки-файлы. Оставаясь на сайте, Вы соглашаетесь на их использование. Для получения дополнительной информации, пожалуйста, ознакомьтесь с политикой в отношении персональных данных.