WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Купить персональные IPV4 и IPV6 прокси
функция не описана

comment_exists() WP 2.0.0

Determine if a comment exists based on author and date.

For best performance, use $timezone = 'gmt', which queries a field that is properly indexed. The default value for $timezone is 'blog' for legacy reasons.

Хуков нет.

Возвращает

Разное. Comment post ID on success.

Использование

comment_exists( $comment_author, $comment_date, $timezone );
$comment_author(строка) (обязательный)
Author of the comment.
$comment_date(строка) (обязательный)
Date of the comment.
$timezone(строка)
Timezone. Accepts 'blog' or 'gmt'.
По умолчанию: 'blog'

Заметки

  • Global. wpdb. $wpdb WordPress database abstraction object.

Список изменений

С версии 2.0.0 Введена.
С версии 4.4.0 Added the $timezone parameter.

Код comment exists: wp-admin/includes/comment.php WP 5.2.2

<?php
function comment_exists( $comment_author, $comment_date, $timezone = 'blog' ) {
	global $wpdb;

	$date_field = 'comment_date';
	if ( 'gmt' === $timezone ) {
		$date_field = 'comment_date_gmt';
	}

	return $wpdb->get_var(
		$wpdb->prepare(
			"SELECT comment_post_ID FROM $wpdb->comments
			WHERE comment_author = %s AND $date_field = %s",
			stripslashes( $comment_author ),
			stripslashes( $comment_date )
		)
	);
}