# get_edit_comment_link()

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

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

## Сигнатура

```php
get_edit_comment_link( int|WP_Comment $comment_id, string $context = 'display' ): string|null
```

## Описание

Извлекает ссылку для редактирования комментария.

## Параметры

- `$comment_id` `int|WP_Comment` — необязательный. Идентификатор комментария или объект WP_Comment.
- `$context` `string` — необязательный, по умолчанию `'display'`. Контекст, в котором будет использоваться URL. Либо 'display' (для включения HTML-сущностей), либо 'url'. По умолчанию 'display'.

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

`string|null`

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

Файл: `wp-includes/link-template.php:1605`

```php
function get_edit_comment_link( $comment_id = 0, $context = 'display' ) {
	$comment = get_comment( $comment_id );

	if ( ! is_object( $comment ) || ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
		return null;
	}

	if ( 'display' === $context ) {
		$action = 'comment.php?action=editcomment&amp;c=';
	} else {
		$action = 'comment.php?action=editcomment&c=';
	}

	$location = admin_url( $action ) . $comment->comment_ID;

	// Ensure the $comment_id variable passed to the filter is always an ID.
	$comment_id = (int) $comment->comment_ID;

	/**
	 * Filters the comment edit link.
	 *
	 * @since 2.3.0
	 * @since 6.7.0 The `$comment_id` and `$context` parameters are now being passed to the filter.
	 *
	 * @param string $location   The edit link.
	 * @param int    $comment_id Unique ID of the comment to generate an edit link.
	 * @param string $context    Context to include HTML entities in link. Default 'display'.
	 */
	return apply_filters( 'get_edit_comment_link', $location, $comment_id, $context );
}
```

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

- 6.7.0 — The $context parameter was added.
- 2.3.0 — Introduced.

## Связанные

Использует: [`current_user_can`](https://chugunov.pro/api-wordpress/functions/current_user_can/), [`admin_url`](https://chugunov.pro/api-wordpress/functions/admin_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_comment`](https://chugunov.pro/api-wordpress/functions/get_comment/).
Используется в: [`edit_comment_link`](https://chugunov.pro/api-wordpress/functions/edit_comment_link/).

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