Docs: Improve documentation for esc_attr_e()
, esc_html_e()
, esc_attr_x()
, esc_html_x()
.
Props atachibana. Fixes #48383. git-svn-id: https://develop.svn.wordpress.org/trunk@46593 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e2c34a76f9
commit
c951d94c72
@ -169,7 +169,7 @@ function determine_locale() {
|
||||
* @param string $text Text to translate.
|
||||
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
|
||||
* Default 'default'.
|
||||
* @return string Translated text
|
||||
* @return string Translated text.
|
||||
*/
|
||||
function translate( $text, $domain = 'default' ) {
|
||||
$translations = get_translations_for_domain( $domain );
|
||||
@ -210,8 +210,7 @@ function before_last_bar( $string ) {
|
||||
/**
|
||||
* Retrieve the translation of $text in the context defined in $context.
|
||||
*
|
||||
* If there is no translation, or the text domain isn't loaded the original
|
||||
* text is returned.
|
||||
* If there is no translation, or the text domain isn't loaded, the original text is returned.
|
||||
*
|
||||
* *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions.
|
||||
*
|
||||
@ -282,7 +281,7 @@ function esc_attr__( $text, $domain = 'default' ) {
|
||||
* @param string $text Text to translate.
|
||||
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
|
||||
* Default 'default'.
|
||||
* @return string Translated text
|
||||
* @return string Translated text.
|
||||
*/
|
||||
function esc_html__( $text, $domain = 'default' ) {
|
||||
return esc_html( translate( $text, $domain ) );
|
||||
@ -304,6 +303,11 @@ function _e( $text, $domain = 'default' ) {
|
||||
/**
|
||||
* Display translated text that has been escaped for safe use in an attribute.
|
||||
*
|
||||
* Encodes `< > & " '` (less than, greater than, ampersand, double quote, single quote).
|
||||
* Will never double encode entities.
|
||||
*
|
||||
* If you need the value for use in PHP, use esc_attr__().
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $text Text to translate.
|
||||
@ -317,6 +321,11 @@ function esc_attr_e( $text, $domain = 'default' ) {
|
||||
/**
|
||||
* Display translated text that has been escaped for safe use in HTML output.
|
||||
*
|
||||
* If there is no translation, or the text domain isn't loaded, the original text
|
||||
* is escaped and displayed.
|
||||
*
|
||||
* If you need the value for use in PHP, use esc_html__().
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $text Text to translate.
|
||||
@ -366,13 +375,16 @@ function _ex( $text, $context, $domain = 'default' ) {
|
||||
/**
|
||||
* Translate string with gettext context, and escapes it for safe use in an attribute.
|
||||
*
|
||||
* If there is no translation, or the text domain isn't loaded, the original text
|
||||
* is escaped and returned.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $text Text to translate.
|
||||
* @param string $context Context information for the translators.
|
||||
* @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
|
||||
* Default 'default'.
|
||||
* @return string Translated text
|
||||
* @return string Translated text.
|
||||
*/
|
||||
function esc_attr_x( $text, $context, $domain = 'default' ) {
|
||||
return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
|
||||
@ -381,6 +393,9 @@ function esc_attr_x( $text, $context, $domain = 'default' ) {
|
||||
/**
|
||||
* Translate string with gettext context, and escapes it for safe use in HTML output.
|
||||
*
|
||||
* If there is no translation, or the text domain isn't loaded, the original text
|
||||
* is escaped and returned.
|
||||
*
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @param string $text Text to translate.
|
||||
|
Loading…
Reference in New Issue
Block a user