# wp_check_comment_data_max_lengths()

URL: https://chugunov.pro/api-wordpress/functions/wp_check_comment_data_max_lengths/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.7.0.

## Сигнатура

```php
wp_check_comment_data_max_lengths( array $comment_data ): WP_Error|true
```

## Описание

Сравнивает длину данных комментария с максимальными ограничениями по количеству символов.

## Параметры

- `$comment_data` `array` — обязательный. Массив аргументов для вставки комментария.

## Возвращаемое значение

`WP_Error|true` — WP_Error

## Исходный код

Файл: `wp-includes/comment.php:1261`

```php
function wp_check_comment_data_max_lengths( $comment_data ) {
	$max_lengths = wp_get_comment_fields_max_lengths();

	if ( isset( $comment_data['comment_author'] ) && mb_strlen( $comment_data['comment_author'], '8bit' ) > $max_lengths['comment_author'] ) {
		return new WP_Error( 'comment_author_column_length', __( '<strong>Error:</strong> Your name is too long.' ), 200 );
	}

	if ( isset( $comment_data['comment_author_email'] ) && strlen( $comment_data['comment_author_email'] ) > $max_lengths['comment_author_email'] ) {
		return new WP_Error( 'comment_author_email_column_length', __( '<strong>Error:</strong> Your email address is too long.' ), 200 );
	}

	if ( isset( $comment_data['comment_author_url'] ) && strlen( $comment_data['comment_author_url'] ) > $max_lengths['comment_author_url'] ) {
		return new WP_Error( 'comment_author_url_column_length', __( '<strong>Error:</strong> Your URL is too long.' ), 200 );
	}

	if ( isset( $comment_data['comment_content'] ) && mb_strlen( $comment_data['comment_content'], '8bit' ) > $max_lengths['comment_content'] ) {
		return new WP_Error( 'comment_content_column_length', __( '<strong>Error:</strong> Your comment is too long.' ), 200 );
	}

	return true;
}
```

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

- 4.7.0 — Introduced.

## Связанные

Использует: [`wp_get_comment_fields_max_lengths`](https://chugunov.pro/api-wordpress/functions/wp_get_comment_fields_max_lengths/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), `WP_Error::__construct`.
Используется в: `WP_REST_Comments_Controller::update_item`, `WP_REST_Comments_Controller::create_item`, [`wp_handle_comment_submission`](https://chugunov.pro/api-wordpress/functions/wp_handle_comment_submission/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_check_comment_data_max_lengths/
