esc_html_e() WP 2.8.0
Translates specified string and replaces special characters in it with HTML entities. Displays text that can be used in HTML as HTML code.
If you need to get the same sting without printing it — just use esc_html__().
Works based on:
esc_html()
, translate()
No Hooks.
Return
Nothing (null).
Usage
esc_html_e( $text, $domain );
- $text(string) (required)
- Text to translate.
- $domain(string)
- Text domain. Unique identifier for retrieving translated strings.
Default: 'default'
Examples
#1 Output in the tag
If the translation has HTML tags or characters that need to be shown as it is, for example in <textarea>
tag, then it is smart to translate such a string with this function:
<textarea> <?php echo esc_html__('Any text with <span>HTML.</span>', 'kama'); ?> </textarea>
#1.2 Same as in the first example but in a different way
<?php echo esc_html( __('Any text with <div>HTML.</div>', 'kama') ); // Or so echo esc_html__('Any text with <div>HTML.</div>', 'kama');