get_comment_type()WP 1.5.0

Получает тип указанного или текущего в цикле комментария.

Основа для: comment_type()
1 раз — 0.000483 сек (быстро) | 50000 раз — 0.13 сек (очень быстро) | PHP 7.0.32, WP 5.1
Хуки из функции

Возвращает

Строку. Тип комментария.

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

get_comment_type( $comment_ID );
$comment_ID(число/WP_Comment) (обязательный)
Объект WP_Comment или ID комментария, тип которого нужно получить.
По умолчанию: 0 (текущий комментарий в цикле)

Примеры

0

#1 Получим тип указанного комментария

echo get_comment_type( 123 ); // > comment

echo get_comment_type( 125 ); // > trackback

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

С версии 1.5.0 Введена.
С версии 4.4.0 Added the ability for $comment_id to also accept a WP_Comment object.

Код get_comment_type() WP 6.5.2

function get_comment_type( $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	if ( '' === $comment->comment_type ) {
		$comment->comment_type = 'comment';
	}

	/**
	 * Filters the returned comment type.
	 *
	 * @since 1.5.0
	 * @since 4.1.0 The `$comment_id` and `$comment` parameters were added.
	 *
	 * @param string     $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
	 * @param string     $comment_id   The comment ID as a numeric string.
	 * @param WP_Comment $comment      The comment object.
	 */
	return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
}