esc_html__( string $text, string $domain = 'default' )
Retrieve the translation of $text and escapes it for safe use in HTML output.
Description Description
If there is no translation, or the text domain isn’t loaded, the original text is escaped and returned.
Parameters Parameters
- $text
-
(string) (Required) Text to translate.
- $domain
-
(string) (Optional) Text domain. Unique identifier for retrieving translated strings.
Default value: 'default'
Return Return
(string) Translated text
Source Source
File: wp-includes/l10n.php
function esc_html__( $text, $domain = 'default' ) { return esc_html( translate( $text, $domain ) ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
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.