esc_attr_x()WP 2.8.0

Translate string with gettext context, and escapes it for safe use in an attribute.

If there is no translation, or the text domain isn't loaded, the original text is escaped and returned.

No Hooks.


String. Translated text.


esc_attr_x( $text, $context, $domain );
$text(string) (required)
Text to translate.
$context(string) (required)
Context information for the translators.
Text domain. Unique identifier for retrieving translated strings.
Default: 'default'


Since 2.8.0 Introduced.

Code of esc_attr_x() WP 6.0

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