esc_html_x() WordPress Function
The esc_html_x() function is used to escape HTMLspecial characters in a string. This function is similar to theesc_html() function, but with one additional argument. The first argument is the string to be escaped, and the second argument is the context. The context can be one of the following values: - 'single': Escapes HTMLspecial characters for use in a single quoted attribute value. - 'double': Escapes HTMLspecial characters for use in a double quoted attribute value. - 'entity': Escapes HTMLspecial characters for use in an HTML entity. - 'html': Escapes HTMLspecial characters for use in an HTML document. - 'js':Escapes HTMLspecial characters for use in a JavaScript context. - 'url': Escapes HTMLspecial characters for use in a URL.
esc_html_x( string $text, string $context, string $domain = 'default' ) #
Translate string with gettext context, 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
(string)(Required)Text to translate.
- $context
(string)(Required)Context information for the translators.
- $domain
(string)(Optional) Text domain. Unique identifier for retrieving translated strings.
Default value: 'default'
Return
(string) Translated text.
Source
File: wp-includes/l10n.php
function esc_html_x( $text, $context, $domain = 'default' ) { return esc_html( translate_with_gettext_context( $text, $context, $domain ) ); }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |