# wp_ajax_dim_comment()

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

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

## Сигнатура

```php
wp_ajax_dim_comment()
```

## Описание

Обрабатывает приглушение комментария через AJAX.

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

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

```php
function wp_ajax_dim_comment() {
	$id      = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
	$comment = get_comment( $id );

	if ( ! $comment ) {
		$response = new WP_Ajax_Response(
			array(
				'what' => 'comment',
				'id'   => new WP_Error(
					'invalid_comment',
					/* translators: %d: Comment ID. */
					sprintf( __( 'Comment %d does not exist' ), $id )
				),
			)
		);
		$response->send();
	}

	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) && ! current_user_can( 'moderate_comments' ) ) {
		wp_die( -1 );
	}

	$current = wp_get_comment_status( $comment );

	if ( isset( $_POST['new'] ) && $_POST['new'] === $current ) {
		wp_die( time() );
	}

	check_ajax_referer( "approve-comment_$id" );

	if ( in_array( $current, array( 'unapproved', 'spam' ), true ) ) {
		$result = wp_set_comment_status( $comment, 'approve', true );
	} else {
		$result = wp_set_comment_status( $comment, 'hold', true );
	}

	if ( is_wp_error( $result ) ) {
		$response = new WP_Ajax_Response(
			array(
				'what' => 'comment',
				'id'   => $result,
			)
		);
		$response->send();
	}

	// Decide if we need to send back '1' or a more complicated response including page links and comment counts.
	_wp_ajax_delete_comment_response( $comment->comment_ID );
	wp_die( 0 );
}
```

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

- 3.1.0 — Introduced.

## Связанные

Использует: [`_wp_ajax_delete_comment_response`](https://chugunov.pro/api-wordpress/functions/_wp_ajax_delete_comment_response/), `WP_Ajax_Response::__construct`, `WP_Ajax_Response::add`, [`wp_set_comment_status`](https://chugunov.pro/api-wordpress/functions/wp_set_comment_status/), [`wp_get_comment_status`](https://chugunov.pro/api-wordpress/functions/wp_get_comment_status/), [`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/), `WP_Error::__construct`.

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