From 552852d887db13e56eead7172aa179ee2cf65979 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 26 Oct 2019 17:30:03 +0000 Subject: [PATCH] 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 --- wp-includes/l10n.php | 25 ++++++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 419ebc3817..ff2bbf7787 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 22f3893628..5dde2789f1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.