# wp_ajax_edit_comment()

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

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

## Сигнатура

```php
wp_ajax_edit_comment()
```

## Описание

Обрабатывает редактирование комментария через AJAX.

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

Файл: `wp-admin/includes/ajax-actions.php:1468`

```php
function wp_ajax_edit_comment() {
	check_ajax_referer( 'replyto-comment', '_ajax_nonce-replyto-comment' );

	$comment_id = (int) $_POST['comment_ID'];

	if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
		wp_die( -1 );
	}

	if ( '' === $_POST['content'] ) {
		wp_die( __( 'Please type your comment text.' ) );
	}

	if ( isset( $_POST['status'] ) ) {
		$_POST['comment_status'] = $_POST['status'];
	}

	$updated = edit_comment();
	if ( is_wp_error( $updated ) ) {
		wp_die( $updated->get_error_message() );
	}

	$position = ( isset( $_POST['position'] ) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
	/*
	 * Checkbox is used to differentiate between the Edit Comments screen (1)
	 * and the Comments section on the Edit Post screen (0).
	 */
	$checkbox      = ( isset( $_POST['checkbox'] ) && '1' === $_POST['checkbox'] ) ? 1 : 0;
	$wp_list_table = _get_list_table( $checkbox ? 'WP_Comments_List_Table' : 'WP_Post_Comments_List_Table', array( 'screen' => 'edit-comments' ) );

	$comment = get_comment( $comment_id );

	if ( empty( $comment->comment_ID ) ) {
		wp_die( -1 );
	}

	ob_start();
	$wp_list_table->single_row( $comment );
	$comment_list_item = ob_get_clean();

	$response = new WP_Ajax_Response();

	$response->add(
		array(
			'what'     => 'edit_comment',
			'id'       => $comment->comment_ID,
			'data'     => $comment_list_item,
			'position' => $position,
		)
	);

	$response->send();
}
```

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

- 3.1.0 — Introduced.

## Связанные

Использует: `WP_List_Table::single_row`, [`_get_list_table`](https://chugunov.pro/api-wordpress/functions/_get_list_table/), `WP_List_Table`, [`edit_comment`](https://chugunov.pro/api-wordpress/functions/edit_comment/), `WP_Ajax_Response::__construct`, `WP_Ajax_Response::add`, [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`check_ajax_referer`](https://chugunov.pro/api-wordpress/functions/check_ajax_referer/), [`wp_die`](https://chugunov.pro/api-wordpress/functions/wp_die/), [`get_comment`](https://chugunov.pro/api-wordpress/functions/get_comment/), [`is_wp_error`](https://chugunov.pro/api-wordpress/functions/is_wp_error/).

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