wppaste
WordPress

WP_Sitemaps_Stylesheet

Since
5.5.0
Source
wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php:17
Stylesheet provider class.

Compatibility

WordPress
since 5.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 3

Every hook that fires from inside WP_Sitemaps_Stylesheet, in the order it appears in the class, grouped by the method that fires it.

Methods · 4

Source code

#[AllowDynamicProperties]class WP_Sitemaps_Stylesheet {	/**	 * Renders the XSL stylesheet depending on whether it's the sitemap index or not.	 *	 * @param string $type Stylesheet type. Either 'sitemap' or 'index'.	 */	public function render_stylesheet( $type ) {		header( 'Content-Type: application/xml; charset=UTF-8' ); 		if ( 'sitemap' === $type ) {			// All content is escaped below.			echo $this->get_sitemap_stylesheet();		} 		if ( 'index' === $type ) {			// All content is 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(			'<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. */			esc_xml( __( 'Number of URLs in this XML Sitemap: %s.' ) ),			'<xsl:value-of select="count( sitemap:urlset/sitemap:url )" />'		); 		$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 = <<<XSL<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet		version="1.0"		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"		xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"		exclude-result-prefixes="sitemap"		> 	<xsl:output method="html" encoding="UTF-8" indent="yes" /> 	<!--	  Set variables for whether lastmod, changefreq or priority occur for any url in the sitemap.	  We do this up front because it can be expensive in a large sitemap.	  -->	<xsl:variable name="has-lastmod"    select="count( /sitemap:urlset/sitemap:url/sitemap:lastmod )"    />	<xsl:variable name="has-changefreq" select="count( /sitemap:urlset/sitemap:url/sitemap:changefreq )" />	<xsl:variable name="has-priority"   select="count( /sitemap:urlset/sitemap:url/sitemap:priority )"   /> 	<xsl:template match="/">		<html {$lang}>			<head>				<title>{$title}</title>				<style>					{$css}				</style>			</head>			<body>				<div id="sitemap">					<div id="sitemap__header">

Changelog

Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/sitemaps/class-wp-sitemaps-stylesheet.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.