PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
jetpack / modules / sitemaps / sitemap-buffer-news.php

sitemap-buffer-news.php in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.5, at modules/sitemaps/sitemap-buffer-news.php

87 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 // phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
3 /**
4 * Sitemaps (per the protocol) are essentially lists of XML fragments;
5 * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_News
6 * extends the Jetpack_Sitemap_Buffer class to represent the single news sitemap
7 * buffer.
8 *
9 * @since 5.3.0
10 * @package automattic/jetpack
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit( 0 );
15 }
16
17 /**
18 * A buffer for constructing sitemap news xml files.
19 *
20 * @since 5.3.0
21 */
22 class Jetpack_Sitemap_Buffer_News extends Jetpack_Sitemap_Buffer {
23 /**
24 * Jetpack_Sitemap_Buffer_News constructor.
25 *
26 * @param int $item_limit The maximum size of the buffer in items.
27 * @param int $byte_limit The maximum size of the buffer in bytes.
28 * @param string $time The initial datetime of the buffer. Must be in 'YYYY-MM-DD hh:mm:ss' format.
29 */
30 public function __construct( $item_limit, $byte_limit, $time = '1970-01-01 00:00:00' ) {
31 parent::__construct( $item_limit, $byte_limit, $time );
32
33 $this->doc->appendChild(
34 $this->doc->createComment( "generator='jetpack-" . JETPACK__VERSION . "'" )
35 );
36
37 $this->doc->appendChild(
38 $this->doc->createComment( 'Jetpack_Sitemap_Buffer_News' )
39 );
40
41 $this->doc->appendChild(
42 $this->doc->createProcessingInstruction(
43 'xml-stylesheet',
44 'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'news-sitemap.xsl' ) . '"'
45 )
46 );
47 }
48
49 /**
50 * Returns a DOM element that contains all news sitemap elements.
51 */
52 protected function get_root_element() {
53 if ( ! isset( $this->root ) ) {
54
55 /**
56 * Filter the attribute value pairs used for namespace and namespace URI mappings.
57 *
58 * @module sitemaps
59 *
60 * @since 4.8.0
61 *
62 * @param array $namespaces Associative array with namespaces and namespace URIs.
63 */
64 $namespaces = apply_filters(
65 'jetpack_sitemap_news_ns',
66 array(
67 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
68 'xmlns:news' => 'http://www.google.com/schemas/sitemap-news/0.9',
69 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
70 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
71 )
72 );
73
74 $this->root = $this->doc->createElement( 'urlset' );
75
76 foreach ( $namespaces as $name => $value ) {
77 $this->root->setAttribute( $name, $value );
78 }
79
80 $this->doc->appendChild( $this->root );
81 $this->byte_capacity -= strlen( $this->doc->saveXML( $this->root ) );
82 }
83
84 return $this->root;
85 }
86 }
87