sitemap-buffer-master.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Sitemaps (per the protocol) are essentially lists of XML fragments;
  4. * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Master
  5. * extends the Jetpack_Sitemap_Buffer class to represent the master sitemap
  6. * buffer.
  7. *
  8. * @since 5.3.0
  9. * @package Jetpack
  10. */
  11. /**
  12. * A buffer for constructing master sitemap xml files.
  13. *
  14. * @since 5.3.0
  15. */
  16. class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer {
  17. public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
  18. parent::__construct( $item_limit, $byte_limit, $time );
  19. $this->doc->appendChild(
  20. $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" )
  21. );
  22. $this->doc->appendChild(
  23. $this->doc->createProcessingInstruction(
  24. 'xml-stylesheet',
  25. 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"'
  26. )
  27. );
  28. }
  29. protected function get_root_element() {
  30. if ( ! isset( $this->root ) ) {
  31. $this->root = $this->doc->createElement( 'sitemapindex' );
  32. $this->root->setAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' );
  33. $this->doc->appendChild( $this->root );
  34. $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) );
  35. }
  36. return $this->root;
  37. }
  38. }