WordPress.org

Make WordPress Core

Ticket #50551: 50551.diff

File 50551.diff, 2.1 KB (added by swissspidy, 5 months ago)
  • src/wp-includes/l10n.php

    diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
    index 226cc2d8fd..61fd92dcea 100644
    function esc_html_e( $text, $domain = 'default' ) { 
    371371        echo esc_html( translate( $text, $domain ) );
    372372}
    373373
     374/**
     375 * Retrieve the translation of $text and escapes it for safe use in XML output.
     376 *
     377 * If there is no translation, or the text domain isn't loaded, the original text
     378 * is escaped and returned.
     379 *
     380 * @since 5.5.0
     381 *
     382 * @param string $text   Text to translate.
     383 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     384 *                       Default 'default'.
     385 * @return string Translated text.
     386 */
     387function esc_xml__( $text, $domain = 'default' ) {
     388        return esc_xml( translate( $text, $domain ) );
     389}
     390
     391/**
     392 * Display translated text that has been escaped for safe use in XML output.
     393 *
     394 * If there is no translation, or the text domain isn't loaded, the original text
     395 * is escaped and displayed.
     396 *
     397 * If you need the value for use in PHP, use esc_xml__().
     398 *
     399 * @since 5.5.0
     400 *
     401 * @param string $text   Text to translate.
     402 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
     403 *                       Default 'default'.
     404 */
     405function esc_xml_e( $text, $domain = 'default' ) {
     406        echo esc_xml( translate( $text, $domain ) );
     407}
     408
     409/**
     410 * Translate string with gettext context, and escapes it for safe use in XML output.
     411 *
     412 * If there is no translation, or the text domain isn't loaded, the original text
     413 * is escaped and returned.
     414 *
     415 * @since 5.5.0
     416 *
     417 * @param string $text    Text to translate.
     418 * @param string $context Context information for the translators.
     419 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
     420 *                        Default 'default'.
     421 * @return string Translated text.
     422 */
     423function esc_xml_x( $text, $context, $domain = 'default' ) {
     424        return esc_xml( translate_with_gettext_context( $text, $context, $domain ) );
     425}
     426
    374427/**
    375428 * Retrieve translated string with gettext context.
    376429 *