esc_html_x()
最后更新于:2021-11-26 04:03:27
esc_html_x( string$text, string$context, string$domain=’default’)Translate string with gettext context, and escapes it for safe use in HTML output.
参数
- $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’
响应
(string) Translated text.
源文件
文件: gc-includes/l10n.php
function esc_html_x( $text, $context, $domain = 'default' ) {
return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
}
<!-- Here, we're asking the user to comment (verb): --> <a href="https://https://docs.gechiui.com/"> <?php echo esc_html_x( 'Comment', 'Verb: To leave a comment', // Here's the contextual help 'gcdocs_my_theme' ); ?> </a> <!-- Here, we're simply adding a heading with the text "Comment" (noun) --> <h3> <?php echo esc_html_x( 'Comment', 'Noun: An individual comment', // Here's the contextual help 'gcdocs_my_theme' ); ?> </h3>