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

63 lines
2.0 KiB
PHP
Raw Permalink Normal View History

2022-06-16 14:01:47 +02:00
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
2019-11-15 23:26:29 +01:00
/**
* Sitemaps (per the protocol) are essentially lists of XML fragments;
* lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master
* extends the Jetpack_Sitemap_Buffer class to represent the master sitemap
* buffer.
*
* @since 5.3.0
2021-04-27 08:32:47 +02:00
* @package automattic/jetpack
2019-11-15 23:26:29 +01:00
*/
2025-12-12 13:13:07 +01:00
if ( ! defined( 'ABSPATH' ) ) {
exit( 0 );
}
2019-11-15 23:26:29 +01:00
/**
* A buffer for constructing master sitemap xml files.
*
* @since 5.3.0
*/
class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer {
2022-06-16 14:01:47 +02:00
/**
* Jetpack_Sitemap_Buffer_Master constructor.
*
* @param int $item_limit The maximum size of the buffer in items.
* @param int $byte_limit The maximum size of the buffer in bytes.
* @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
*/
2019-11-15 23:26:29 +01:00
public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
parent::__construct( $item_limit, $byte_limit, $time );
$this->doc->appendChild(
$this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" )
);
2022-12-15 17:41:53 +01:00
$this->doc->appendChild(
$this->doc->createComment( 'Jetpack_Sitemap_Buffer_Master' )
);
2019-11-15 23:26:29 +01:00
$this->doc->appendChild(
$this->doc->createProcessingInstruction(
'xml-stylesheet',
'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"'
)
);
}
2022-06-16 14:01:47 +02:00
/**
* Returns a DOM element that contains all master sitemap elements.
*/
2019-11-15 23:26:29 +01:00
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
$this->root = $this->doc->createElement( 'sitemapindex' );
$this->root->setAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' );
$this->doc->appendChild( $this->root );
$this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) );
}
return $this->root;
}
}