get_sitemap_stylesheet(); } if ( 'index' === $type ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- All content escaped below. echo $this->get_sitemap_index_stylesheet(); } exit; } /** * Returns the escaped XSL for all sitemaps, except index. * * @since 5.5.0 */ public function get_sitemap_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( '%s', esc_url( __( 'https://www.sitemaps.org/' ) ), esc_xml( __( 'Learn more about XML sitemaps.' ) ) ); $text = sprintf( /* translators: %s: Number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ), '' ); $lang = get_language_attributes( 'html' ); $url = esc_xml( __( 'URL' ) ); $lastmod = esc_xml( __( 'Last Modified' ) ); $changefreq = esc_xml( __( 'Change Frequency' ) ); $priority = esc_xml( __( 'Priority' ) ); $xsl_content = << {$title}

{$title}

{$description}

{$learn_more}

{$text}

{$url} {$lastmod} {$changefreq} {$priority}
XSL; /** * Filters the content of the sitemap stylesheet. * * @since 5.5.0 * * @param string $xsl_content Full content for the XML stylesheet. */ return apply_filters( 'wp_sitemaps_stylesheet_content', $xsl_content ); } /** * Returns the escaped XSL for the index sitemaps. * * @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( '%s', esc_url( __( 'https://www.sitemaps.org/' ) ), esc_xml( __( 'Learn more about XML sitemaps.' ) ) ); $text = sprintf( /* translators: %s: Number of URLs. */ esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ), '' ); $lang = get_language_attributes( 'html' ); $url = esc_xml( __( 'URL' ) ); $lastmod = esc_xml( __( 'Last Modified' ) ); $xsl_content = << {$title}

{$title}

{$description}

{$learn_more}

{$text}

{$url} {$lastmod}
XSL; /** * Filters the content of the sitemap index stylesheet. * * @since 5.5.0 * * @param string $xsl_content Full content for the XML stylesheet. */ return apply_filters( 'wp_sitemaps_stylesheet_index_content', $xsl_content ); } /** * Gets the CSS to be included in sitemap XSL stylesheets. * * @since 5.5.0 * * @return string The CSS. */ public function get_stylesheet_css() { $css = ' body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; color: #444; } #sitemap__table { border: solid 1px #ccc; border-collapse: collapse; } #sitemap__table tr th { text-align: left; } #sitemap__table tr td, #sitemap__table tr th { padding: 10px; } #sitemap__table tr:nth-child(odd) td { background-color: #eee; } a:hover { text-decoration: none; }'; /** * Filters the CSS only for the sitemap stylesheet. * * @since 5.5.0 * * @param string $css CSS to be applied to default XSL file. */ return apply_filters( 'wp_sitemaps_stylesheet_css', $css ); } }