Skip to content

Commit

Permalink
Coding Standards: Fix WPCS issues in wp-includes/sitemaps/.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
SergeyBiryukov committed Jun 18, 2020
1 parent 74967e4 commit ce95560
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/wp-includes/sitemaps/class-wp-sitemaps-renderer.php
Expand Up @@ -40,10 +40,13 @@ class WP_Sitemaps_Renderer {
*/
public function __construct() {
$stylesheet_url = $this->get_sitemap_stylesheet_url();

if ( $stylesheet_url ) {
$this->stylesheet = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_url ) . '" ?>';
}
$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 = '<?xml-stylesheet type="text/xsl" href="' . esc_url( $stylesheet_index_url ) . '" ?>';
}
Expand Down Expand Up @@ -160,8 +163,8 @@ public function get_sitemap_index_xml( $sitemaps ) {
} 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' ) )
),
Expand Down Expand Up @@ -225,8 +228,8 @@ public function get_sitemap_xml( $url_list ) {
} 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' ) )
),
Expand Down
12 changes: 6 additions & 6 deletions src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php
Expand Up @@ -52,7 +52,7 @@ public function get_sitemap_stylesheet() {
);

$text = sprintf(
/* translators: %s: number of URLs. */
/* translators: %s: Number of URLs. */
esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ),
'<xsl:value-of select="count( sitemap:urlset/sitemap:url )" />'
);
Expand Down Expand Up @@ -152,17 +152,17 @@ public function get_sitemap_stylesheet() {
* @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(
'<a href="%s">%s</a>',
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.' ) ),
'<xsl:value-of select="count( sitemap:sitemapindex/sitemap:sitemap )" />'
);
Expand Down
5 changes: 3 additions & 2 deletions src/wp-includes/sitemaps/class-wp-sitemaps.php
Expand Up @@ -207,8 +207,9 @@ public function redirect_sitemapxml( $bypass, $query ) {
}

// '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();
}
Expand Down

0 comments on commit ce95560

Please sign in to comment.