# esc_attr_x()

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

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

## Сигнатура

```php
esc_attr_x( string $text, string $context, string $domain = 'default' ): string
```

## Описание

Если перевода нет или текстовый домен не загружен, исходный текст экранируется и возвращается.

## Параметры

- `$text` `string` — обязательный. Текст для перевода.
- `$context` `string` — обязательный. Контекстная информация для переводчиков.
- `$domain` `string` — необязательный, по умолчанию `'default'`. Текстовый домен. Уникальный идентификатор для получения переведённых строк.
  
  Значение по умолчанию: 'default'.

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

`string`

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

Файл: `wp-includes/l10n.php:441`

```php
function esc_attr_x( $text, $context, $domain = 'default' ) {
	return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
}
```

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

- 2.8.0 — Introduced.

## Связанные

Использует: [`translate_with_gettext_context`](https://chugunov.pro/api-wordpress/functions/translate_with_gettext_context/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/).
Используется в: [`wp_print_revision_templates`](https://chugunov.pro/api-wordpress/functions/wp_print_revision_templates/), [`wp_dropdown_languages`](https://chugunov.pro/api-wordpress/functions/wp_dropdown_languages/), [`post_submit_meta_box`](https://chugunov.pro/api-wordpress/functions/post_submit_meta_box/), [`get_search_form`](https://chugunov.pro/api-wordpress/functions/get_search_form/), [`get_the_password_form`](https://chugunov.pro/api-wordpress/functions/get_the_password_form/).

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