From ce955603cbc93f564a060395fede879f0d327daa Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 18 Jun 2020 14:43:31 +0000 Subject: [PATCH] Coding Standards: Fix WPCS issues in `wp-includes/sitemaps/`. Some of these were not caught when running `composer lint:errors`, but are fixed when running `phpcbf` directly. Follow-up to [48072], [48080]. See #49542, #50117. git-svn-id: https://develop.svn.wordpress.org/trunk@48081 602fd350-edb4-49c9-b593-d223f7449a82 --- .../sitemaps/class-wp-sitemaps-renderer.php | 9 ++++++--- .../sitemaps/class-wp-sitemaps-stylesheet.php | 12 ++++++------ src/wp-includes/sitemaps/class-wp-sitemaps.php | 5 +++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php b/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php index 860f74242d..373a9dbdaf 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php @@ -40,10 +40,13 @@ class WP_Sitemaps_Renderer { */ public function __construct() { $stylesheet_url = $this->get_sitemap_stylesheet_url(); + if ( $stylesheet_url ) { $this->stylesheet = ''; } - $stylesheet_index_url = $this->get_sitemap_index_stylesheet_url(); + + $stylesheet_index_url = $this->get_sitemap_index_stylesheet_url(); + if ( $stylesheet_index_url ) { $this->stylesheet_index = ''; } @@ -160,8 +163,8 @@ class WP_Sitemaps_Renderer { } else { _doing_it_wrong( __METHOD__, - /* translators: %s: list of element names */ sprintf( + /* translators: %s: List of element names. */ __( 'Fields other than %s are not currently supported for the sitemap index.' ), implode( ',', array( 'loc', 'lastmod' ) ) ), @@ -225,8 +228,8 @@ class WP_Sitemaps_Renderer { } else { _doing_it_wrong( __METHOD__, - /* translators: %s: list of element names */ sprintf( + /* translators: %s: List of element names. */ __( 'Fields other than %s are not currently supported for sitemaps.' ), implode( ',', array( 'loc', 'lastmod', 'changefreq', 'priority' ) ) ), diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php b/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php index 3a80a7e2cd..66ad2e399d 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php @@ -52,7 +52,7 @@ class WP_Sitemaps_Stylesheet { ); $text = sprintf( - /* translators: %s: number of URLs. */ + /* translators: %s: Number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ), '' ); @@ -152,17 +152,17 @@ XSL; * @since 5.5.0 */ public function get_sitemap_index_stylesheet() { - $css = $this->get_stylesheet_css(); - $title = esc_xml( __( 'XML Sitemap' ) ); - $description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ) ); - $learn_more = sprintf( + $css = $this->get_stylesheet_css(); + $title = esc_xml( __( 'XML Sitemap' ) ); + $description = esc_xml( __( 'This XML Sitemap is generated by WordPress to make your content more visible for search engines.' ) ); + $learn_more = sprintf( '%s', esc_url( __( 'https://www.sitemaps.org/' ) ), esc_xml( __( 'Learn more about XML sitemaps.' ) ) ); $text = sprintf( - /* translators: %s: number of URLs. */ + /* translators: %s: Number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ), '' ); diff --git a/src/wp-includes/sitemaps/class-wp-sitemaps.php b/src/wp-includes/sitemaps/class-wp-sitemaps.php index 6c6a795af8..1e72f13d51 100644 --- a/src/wp-includes/sitemaps/class-wp-sitemaps.php +++ b/src/wp-includes/sitemaps/class-wp-sitemaps.php @@ -207,8 +207,9 @@ class WP_Sitemaps { } // 'pagename' is for most permalink types, name is for when the %postname% is used as a top-level field. - if ( 'sitemap-xml' === $query->get( 'pagename' ) || - 'sitemap-xml' === $query->get( 'name' ) ) { + if ( 'sitemap-xml' === $query->get( 'pagename' ) + || 'sitemap-xml' === $query->get( 'name' ) + ) { wp_safe_redirect( $this->index->get_index_url() ); exit(); }