Code Duplication    Length = 50-51 lines in 4 locations

modules/sitemaps/sitemap-buffer-image.php 1 location

@@ 17-67 (lines=51) @@
14
 *
15
 * @since 5.1.0
16
 */
17
class Jetpack_Sitemap_Buffer_Image 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( 'image-sitemap.xsl' ) . '"'
30
			)
31
		);
32
	}
33
34
	protected function get_root_element() {
35
		if ( ! isset( $this->root ) ) {
36
37
			/**
38
			 * Filter the XML namespaces included in image sitemaps.
39
			 *
40
			 * @module sitemaps
41
			 *
42
			 * @since 4.8.0
43
			 *
44
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
45
			 */
46
			$namespaces = apply_filters(
47
				'jetpack_sitemap_image_ns',
48
				array(
49
					'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
50
					'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
51
					'xmlns'              => 'http://www.sitemaps.org/schemas/sitemap/0.9',
52
					'xmlns:image'        => 'http://www.google.com/schemas/sitemap-image/1.1',
53
				)
54
			);
55
56
			$this->root = $this->doc->createElement( 'urlset' );
57
58
			foreach ( $namespaces as $name => $value ) {
59
				$this->root->setAttribute( $name, $value );
60
			}
61
62
			$this->doc->appendChild( $this->root );
63
		}
64
65
		return $this->root;
66
	}
67
}
68

modules/sitemaps/sitemap-buffer-news.php 1 location

@@ 17-67 (lines=51) @@
14
 *
15
 * @since 5.1.0
16
 */
17
class Jetpack_Sitemap_Buffer_News 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( 'news-sitemap.xsl' ) . '"'
30
			)
31
		);
32
	}
33
34
	protected function get_root_element() {
35
		if ( ! isset( $this->root ) ) {
36
37
			/**
38
			 * Filter the attribute value pairs used for namespace and namespace URI mappings.
39
			 *
40
			 * @module sitemaps
41
			 *
42
			 * @since 4.8.0
43
			 *
44
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
45
			 */
46
			$namespaces = apply_filters(
47
				'jetpack_sitemap_news_ns',
48
				array(
49
					'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
50
					'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
51
					'xmlns'              => 'http://www.sitemaps.org/schemas/sitemap/0.9',
52
					'xmlns:news'         => 'http://www.google.com/schemas/sitemap-news/0.9',
53
				)
54
			);
55
56
			$this->root = $this->doc->createElement( 'urlset' );
57
58
			foreach ( $namespaces as $name => $value ) {
59
				$this->root->setAttribute( $name, $value );
60
			}
61
62
			$this->doc->appendChild( $this->root );
63
		}
64
65
		return $this->root;
66
	}
67
}
68

modules/sitemaps/sitemap-buffer-page.php 1 location

@@ 17-66 (lines=50) @@
14
 *
15
 * @since 5.1.0
16
 */
17
class Jetpack_Sitemap_Buffer_Page 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.xsl' ) . '"'
30
			)
31
		);
32
	}
33
34
	protected function get_root_element() {
35
		if ( ! isset( $this->root ) ) {
36
37
			/**
38
			 * Filter the attribute value pairs used for namespace and namespace URI mappings.
39
			 *
40
			 * @module sitemaps
41
			 *
42
			 * @since 3.9.0
43
			 *
44
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
45
			 */
46
			$namespaces = apply_filters(
47
				'jetpack_sitemap_ns',
48
				array(
49
					'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
50
					'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
51
					'xmlns'              => 'http://www.sitemaps.org/schemas/sitemap/0.9',
52
				)
53
			);
54
55
			$this->root = $this->doc->createElement( 'urlset' );
56
57
			foreach ( $namespaces as $name => $value ) {
58
				$this->root->setAttribute( $name, $value );
59
			}
60
61
			$this->doc->appendChild( $this->root );
62
		}
63
64
		return $this->root;
65
	}
66
}
67

modules/sitemaps/sitemap-buffer-video.php 1 location

@@ 17-67 (lines=51) @@
14
 *
15
 * @since 5.1.0
16
 */
17
class Jetpack_Sitemap_Buffer_Video 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( 'video-sitemap.xsl' ) . '"'
30
			)
31
		);
32
	}
33
34
	protected function get_root_element() {
35
		if ( ! isset( $this->root ) ) {
36
37
			/**
38
			 * Filter the XML namespaces included in video sitemaps.
39
			 *
40
			 * @module sitemaps
41
			 *
42
			 * @since 4.8.0
43
			 *
44
			 * @param array $namespaces Associative array with namespaces and namespace URIs.
45
			 */
46
			$namespaces = apply_filters(
47
				'jetpack_sitemap_video_ns',
48
				array(
49
					'xmlns:xsi'          => 'http://www.w3.org/2001/XMLSchema-instance',
50
					'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
51
					'xmlns'              => 'http://www.sitemaps.org/schemas/sitemap/0.9',
52
					'xmlns:video'        => 'http://www.google.com/schemas/sitemap-video/1.1',
53
				)
54
			);
55
56
			$this->root = $this->doc->createElement( 'urlset' );
57
58
			foreach ( $namespaces as $name => $value ) {
59
				$this->root->setAttribute( $name, $value );
60
			}
61
62
			$this->doc->appendChild( $this->root );
63
		}
64
65
		return $this->root;
66
	}
67
}
68