Retrieves the translation of $text and escapes it for safe use in HTML output.
Description
If there is no translation, or the text domain isn’t loaded, the original text is escaped and returned.
Parameters
$text
stringrequired- Text to translate.
$domain
stringoptional- Text domain. Unique identifier for retrieving translated strings.
Default'default'
.Default:
'default'
Source
function esc_html__( $text, $domain = 'default' ) {
return esc_html( translate( $text, $domain ) );
}
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
Use to embed translations inside HTML. This way you ensure that third party translation are sanitized and will not break the code (proper security to keep the users safe).
When using
esc_html__
, remember that it’s also possible to echo the string value out by using the relatedesc_html_e
which does the same thing but echoes the string too.An example:
You can also read more about
esc_html_e
too.