Docs: Improve documentation for `esc_attr_e()`, `esc_html_e()`, `esc_attr_x()`, `esc_html_x()`.

Props atachibana.
Fixes #48383.
Built from https://develop.svn.wordpress.org/trunk@46593


git-svn-id: http://core.svn.wordpress.org/trunk@46390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-10-26 17:30:03 +00:00
parent ac3ff7eb1a
commit 552852d887
2 changed files with 21 additions and 6 deletions

View File

@ -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.

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-46592';
$wp_version = '5.4-alpha-46593';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.