sitemap-buffer-factory.php
1 year ago
sitemap-buffer-fallback.php
2 years ago
sitemap-buffer-image-fallback.php
2 years ago
sitemap-buffer-image-xmlwriter.php
1 year ago
sitemap-buffer-image.php
4 years ago
sitemap-buffer-master-fallback.php
2 years ago
sitemap-buffer-master-xmlwriter.php
1 year ago
sitemap-buffer-master.php
4 years ago
sitemap-buffer-news-fallback.php
2 years ago
sitemap-buffer-news-xmlwriter.php
1 year ago
sitemap-buffer-news.php
4 years ago
sitemap-buffer-page-fallback.php
2 years ago
sitemap-buffer-page-xmlwriter.php
1 year ago
sitemap-buffer-page.php
4 years ago
sitemap-buffer-video-fallback.php
1 year ago
sitemap-buffer-video-xmlwriter.php
1 year ago
sitemap-buffer-video.php
4 years ago
sitemap-buffer-xmlwriter.php
1 year ago
sitemap-buffer.php
1 year ago
sitemap-builder.php
1 year ago
sitemap-constants.php
1 year ago
sitemap-finder.php
2 years ago
sitemap-librarian.php
1 year ago
sitemap-logger.php
1 year ago
sitemap-state.php
2 years ago
sitemap-stylist.php
2 years ago
sitemaps.php
1 year ago
sitemap-buffer-master-xmlwriter.php
52 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * XMLWriter implementation of the master sitemap buffer. |
| 4 | * |
| 5 | * @since 14.6 |
| 6 | * @package automattic/jetpack |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * A buffer for constructing master sitemap xml files using XMLWriter. |
| 11 | * |
| 12 | * @since 14.6 |
| 13 | */ |
| 14 | class Jetpack_Sitemap_Buffer_Master_XMLWriter extends Jetpack_Sitemap_Buffer_XMLWriter { |
| 15 | |
| 16 | /** |
| 17 | * Initialize the buffer with required headers and root element. |
| 18 | */ |
| 19 | protected function initialize_buffer() { |
| 20 | // Add generator comment |
| 21 | $this->writer->writeComment( "generator='jetpack-" . JETPACK__VERSION . "'" ); |
| 22 | $this->writer->writeComment( 'Jetpack_Sitemap_Buffer_Master_XMLWriter' ); |
| 23 | |
| 24 | // Add stylesheet |
| 25 | $this->writer->writePi( |
| 26 | 'xml-stylesheet', |
| 27 | 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"' |
| 28 | ); |
| 29 | |
| 30 | // Start root element with namespaces |
| 31 | $this->writer->startElement( 'sitemapindex' ); |
| 32 | $this->writer->writeAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Append a sitemap entry to the master sitemap. |
| 37 | * |
| 38 | * @param array $array The sitemap item to append. |
| 39 | */ |
| 40 | protected function append_item( $array ) { |
| 41 | if ( ! empty( $array['sitemap'] ) ) { |
| 42 | $this->writer->startElement( 'sitemap' ); |
| 43 | |
| 44 | foreach ( $array['sitemap'] as $tag => $value ) { |
| 45 | $this->writer->writeElement( $tag, strval( $value ) ); |
| 46 | } |
| 47 | |
| 48 | $this->writer->endElement(); // sitemap |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 |