sitemap-buffer-master-fallback.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 for users without libxml support.
  13. *
  14. * @since 5.3.0
  15. */
  16. class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer_Fallback {
  17. protected function get_root_element() {
  18. if ( ! isset( $this->root ) ) {
  19. $sitemap_index_xsl_url = $this->finder->construct_sitemap_url( 'sitemap-index.xsl' );
  20. $jetpack_version = JETPACK__VERSION;
  21. $this->root = array(
  22. "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL
  23. . "<?xml-stylesheet type='text/xsl' href='{$sitemap_index_xsl_url}'?>" . PHP_EOL
  24. . "<sitemapindex xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'>" . PHP_EOL,
  25. '</sitemapindex>'
  26. );
  27. $this->byte_capacity -= strlen( join( '', $this->root ) );
  28. }
  29. return $this->root;
  30. }
  31. }