Completed
Push — update/sitemaps-libxml ( 292726 )
by
unknown
11:41
created

Jetpack_Sitemap_Buffer_Master::get_root_element()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
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.1.0
9
 * @package Jetpack
10
 */
11
12
/**
13
 * A buffer for constructing master sitemap xml files.
14
 *
15
 * @since 5.1.0
16
 */
17
class Jetpack_Sitemap_Buffer_Master extends Jetpack_Sitemap_Buffer {
18
19
	public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
20
		parent::__construct( $item_limit, $byte_limit, $time );
21
22
		$this->doc->appendChild(
23
			$this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" )
24
		);
25
26
		$this->doc->appendChild(
27
			$this->doc->createProcessingInstruction(
28
				'xml-stylesheet',
29
				'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'sitemap-index.xsl' ) . '"'
30
			)
31
		);
32
	}
33
34
	protected function get_root_element() {
35
		if ( ! isset( $this->root ) ) {
36
			$this->root = $this->doc->createElement( 'sitemapindex' );
37
			$this->root->setAttribute( 'xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9' );
38
			$this->doc->appendChild( $this->root );
39
		}
40
41
		return $this->root;
42
	}
43
}
44