kollapsminoriteten/wp-content/plugins/jetpack/modules/sitemaps/sitemap-buffer-master-xmlwr...

54 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2025-05-07 06:48:41 +02:00
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* XMLWriter implementation of the master sitemap buffer.
*
* @since 14.6
* @package automattic/jetpack
*/
2025-12-12 13:13:07 +01:00
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
2025-05-07 06:48:41 +02:00
/**
* A buffer for constructing master sitemap xml files using XMLWriter.
*
* @since 14.6
*/
class Jetpack_Sitemap_Buffer_Master_XMLWriter extends Jetpack_Sitemap_Buffer_XMLWriter {
/**
2025-12-12 13:13:07 +01:00
* Initialize the buffer with required headers (no root element here).
2025-05-07 06:48:41 +02:00
*/
protected function initialize_buffer() {
// Add generator comment
$this->writer->writeComment( "generator='jetpack-" . JETPACK__VERSION . "'" );
$this->writer->writeComment( 'Jetpack_Sitemap_Buffer_Master_XMLWriter' );
// Add stylesheet
$this->writer->writePi(
'xml-stylesheet',
'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"'
);
2025-12-12 13:13:07 +01:00
}
2025-05-07 06:48:41 +02:00
2025-12-12 13:13:07 +01:00
/**
* Start the root element and write its namespaces.
*/
protected function start_root() {
2025-05-07 06:48:41 +02:00
$this->writer->startElement( 'sitemapindex' );
$this->writer->writeAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' );
}
/**
* Append a sitemap entry to the master sitemap.
*
* @param array $array The sitemap item to append.
*/
protected function append_item( $array ) {
if ( ! empty( $array['sitemap'] ) ) {
2025-12-12 13:13:07 +01:00
$this->array_to_xml( $array );
2025-05-07 06:48:41 +02:00
}
}
}