esc_html

Escaping for HTML blocks.

Description

(string) esc_html__( (string) $text, (string) $domain = 'default' ); 

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

  1. if ( !function_exists( 'esc_html__' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // Text to translate. 
  5. $text = ''; 
  6.  
  7. // Optional. Text domain. Unique identifier for retrieving translated strings. 
  8. // Default 'default'. 
  9. $domain = 'default'; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = esc_html__($text, $domain); 
  13.  

Defined (2)

The function is defined in the following location(s).

/wp-includes/l10n.php  
  1. function esc_html__( $text, $domain = 'default' ) { 
  2. return esc_html( translate( $text, $domain ) ); 
/wp-includes/formatting.php  
  1. function esc_html( $text ) { 
  2. $safe_text = wp_check_invalid_utf8( $text ); 
  3. $safe_text = _wp_specialchars( $safe_text, ENT_QUOTES ); 
  4. /** 
  5. * Filter a string cleaned and escaped for output in HTML. 
  6. * Text passed to esc_html() is stripped of invalid or special characters 
  7. * before output. 
  8. * @since 2.8.0 
  9. * @param string $safe_text The text after it has been escaped. 
  10. * @param string $text The text prior to being escaped. 
  11. */ 
  12. return apply_filters( 'esc_html', $safe_text, $text );