esc_html_x( string $text, string $context, string $domain = 'default' ): string
Translates string with gettext context, and escapes it for safe use in HTML output.
Contents
Description
If there is no translation, or the text domain isn’t loaded, the original text is escaped and returned.
Parameters
-
$text
string Required -
Text to translate.
-
$context
string Required -
Context information for the translators.
-
$domain
string Optional -
Text domain. Unique identifier for retrieving translated strings.
Default'default'
.Default:
'default'
Return
string Translated text.
Source
File: wp-includes/l10n.php
.
View all references
function esc_html_x( $text, $context, $domain = 'default' ) {
return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
}
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
The _x functions (like esc_html_x) are essentially the same as their _e counterparts, with an added “context” argument to explain the context a word or phrase is used in. Useful for words with multiple meanings:
Top ↑
Feedback
There’s another key difference, he `_e` counterparts will output where `_x` will not. No need to echo before _e. — By admcfajn —
I think it’s more accurate to say that “_x functions are essentially the same as their __ counterparts”, since _e functions include echo while _x and __ do not. — By Santiago Becerra —