Ticket #50551: 50551.2.diff
| File 50551.2.diff, 6.4 KB (added by , 6 years ago) |
|---|
-
src/wp-includes/l10n.php
From e5f3dc0fde5ea75b26d8763f1199f7daed6acf08 Mon Sep 17 00:00:00 2001 From: Paul Biron <paul@sparrowhawkcomputing.com> Date: Wed, 8 Jul 2020 09:39:40 -0600 Subject: [PATCH] Add l10n helpers for esc_xml() and replace all occurrences of esc_xml( __() ) in core with esc_xml__(). --- src/wp-includes/l10n.php | 53 +++++++++++++++++++ .../sitemaps/class-wp-sitemaps-renderer.php | 4 +- .../sitemaps/class-wp-sitemaps-stylesheet.php | 28 +++++----- 3 files changed, 69 insertions(+), 16 deletions(-) diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index 226cc2d8fd..61fd92dcea 100644
a b function esc_html_e( $text, $domain = 'default' ) { 371 371 echo esc_html( translate( $text, $domain ) ); 372 372 } 373 373 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 */ 387 function 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 */ 405 function 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 */ 423 function esc_xml_x( $text, $context, $domain = 'default' ) { 424 return esc_xml( translate_with_gettext_context( $text, $context, $domain ) ); 425 } 426 374 427 /** 375 428 * Retrieve translated string with gettext context. 376 429 * -
src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php b/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php index c313585d22..c49f5a5962 100644
a b class WP_Sitemaps_Renderer { 261 261 wp_die( 262 262 sprintf( 263 263 /* translators: %s: SimpleXML */ 264 esc_xml ( __( 'Could not generate XML sitemap due to missing %s extension' )),264 esc_xml__( 'Could not generate XML sitemap due to missing %s extension' ), 265 265 'SimpleXML' 266 266 ), 267 esc_xml ( __( 'WordPress › Error' )),267 esc_xml__( 'WordPress › Error' ), 268 268 array( 269 269 'response' => 501, // "Not implemented". 270 270 ) -
src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php b/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php index 490541ab28..57f53c8fdf 100644
a b class WP_Sitemaps_Stylesheet { 43 43 */ 44 44 public function get_sitemap_stylesheet() { 45 45 $css = $this->get_stylesheet_css(); 46 $title = esc_xml ( __( 'XML Sitemap' ));47 $description = esc_xml ( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ));46 $title = esc_xml__( 'XML Sitemap' ); 47 $description = esc_xml__( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ); 48 48 $learn_more = sprintf( 49 49 '<a href="%s">%s</a>', 50 50 esc_url( __( 'https://www.sitemaps.org/' ) ), 51 esc_xml ( __( 'Learn more about XML sitemaps.' ))51 esc_xml__( 'Learn more about XML sitemaps.' ) 52 52 ); 53 53 54 54 $text = sprintf( 55 55 /* translators: %s: Number of URLs. */ 56 esc_xml ( __( 'Number of URLs in this XML Sitemap: %s.' )),56 esc_xml__( 'Number of URLs in this XML Sitemap: %s.' ), 57 57 '<xsl:value-of select="count( sitemap:urlset/sitemap:url )" />' 58 58 ); 59 59 60 60 $lang = get_language_attributes( 'html' ); 61 $url = esc_xml ( __( 'URL' ));62 $lastmod = esc_xml ( __( 'Last Modified' ));63 $changefreq = esc_xml ( __( 'Change Frequency' ));64 $priority = esc_xml ( __( 'Priority' ));61 $url = esc_xml__( 'URL' ); 62 $lastmod = esc_xml__( 'Last Modified' ); 63 $changefreq = esc_xml__( 'Change Frequency' ); 64 $priority = esc_xml__( 'Priority' ); 65 65 66 66 $xsl_content = <<<XSL 67 67 <?xml version="1.0" encoding="UTF-8"?> … … XSL; 153 153 */ 154 154 public function get_sitemap_index_stylesheet() { 155 155 $css = $this->get_stylesheet_css(); 156 $title = esc_xml ( __( 'XML Sitemap' ));157 $description = esc_xml ( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ));156 $title = esc_xml__( 'XML Sitemap' ); 157 $description = esc_xml__( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ); 158 158 $learn_more = sprintf( 159 159 '<a href="%s">%s</a>', 160 160 esc_url( __( 'https://www.sitemaps.org/' ) ), 161 esc_xml ( __( 'Learn more about XML sitemaps.' ))161 esc_xml__( 'Learn more about XML sitemaps.' ) 162 162 ); 163 163 164 164 $text = sprintf( 165 165 /* translators: %s: Number of URLs. */ 166 esc_xml ( __( 'Number of URLs in this XML Sitemap: %s.' )),166 esc_xml__( 'Number of URLs in this XML Sitemap: %s.' ), 167 167 '<xsl:value-of select="count( sitemap:sitemapindex/sitemap:sitemap )" />' 168 168 ); 169 169 170 170 $lang = get_language_attributes( 'html' ); 171 $url = esc_xml ( __( 'URL' ));172 $lastmod = esc_xml ( __( 'Last Modified' ));171 $url = esc_xml__( 'URL' ); 172 $lastmod = esc_xml__( 'Last Modified' ); 173 173 174 174 $xsl_content = <<<XSL 175 175 <?xml version="1.0" encoding="UTF-8"?>