WordPress at a glance
функция не описана

WP_Sitemaps_Renderer::get_sitemap_xml() public WP 5.5.0

Gets XML for a sitemap.

It's a method of the class: WP_Sitemaps_Renderer{}

Хуков нет.

Возвращает

String/false. A well-formed XML string for a sitemap index. False on error.

Использование

$WP_Sitemaps_Renderer = new WP_Sitemaps_Renderer();
$WP_Sitemaps_Renderer->get_sitemap_xml( $url_list );
$url_list(array) (required)
Array of URLs for a sitemap.

Changelog

Since 5.5.0 Introduced.

Код WP_Sitemaps_Renderer::get_sitemap_xml() WP 5.5.1

<?php
public function get_sitemap_xml( $url_list ) {
	$urlset = new SimpleXMLElement(
		sprintf(
			'%1$s%2$s%3$s',
			'<?xml version="1.0" encoding="UTF-8" ?>',
			$this->stylesheet,
			'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'
		)
	);

	foreach ( $url_list as $url_item ) {
		$url = $urlset->addChild( 'url' );

		// Add each element as a child node to the <url> entry.
		foreach ( $url_item as $name => $value ) {
			if ( 'loc' === $name ) {
				$url->addChild( $name, esc_url( $value ) );
			} elseif ( in_array( $name, array( 'lastmod', 'changefreq', 'priority' ), true ) ) {
				$url->addChild( $name, esc_xml( $value ) );
			} else {
				_doing_it_wrong(
					__METHOD__,
					sprintf(
						/* translators: %s: List of element names. */
						__( 'Fields other than %s are not currently supported for sitemaps.' ),
						implode( ',', array( 'loc', 'lastmod', 'changefreq', 'priority' ) )
					),
					'5.5.0'
				);
			}
		}
	}

	return $urlset->asXML();
}