esc_html
Escaping for HTML blocks.
Description
If there is no translation, or the text domain isn't loaded, the original text is returned.
Returns (string)
Translated text
Parameters (2)
- 0. $text (string)
- Text to translate.
- 1. $domain — Optional. (string) =>
'default'
- Text domain. Unique identifier for retrieving translated strings. Default default..
Usage
if ( !function_exists( 'esc_html__' ) ) { require_once ABSPATH . WPINC . '/l10n.php'; } // Text to translate. $text = ''; // Optional. Text domain. Unique identifier for retrieving translated strings. // Default 'default'. $domain = 'default'; // NOTICE! Understand what this does before running. $result = esc_html__($text, $domain);
Defined (2)
The function is defined in the following location(s).
- /wp-includes/l10n.php
- function esc_html__( $text, $domain = 'default' ) {
- return esc_html( translate( $text, $domain ) );
- }
- /wp-includes/formatting.php
- function esc_html( $text ) {
- $safe_text = wp_check_invalid_utf8( $text );
- $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES );
- /**
- * Filters a string cleaned and escaped for output in HTML.
- *
- * Text passed to esc_html() is stripped of invalid or special characters
- * before output.
- *
- * @since 2.8.0
- *
- * @param string $safe_text The text after it has been escaped.
- * @param string $text The text prior to being escaped.
- */
- return apply_filters( 'esc_html', $safe_text, $text );
- }