summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php')
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php
new file mode 100644
index 00000000..d211877d
--- /dev/null
+++ b/plugins/jetpack/modules/sitemaps/sitemap-buffer-video-fallback.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Sitemaps (per the protocol) are essentially lists of XML fragments;
+ * lists which are subject to size constraints. The Jetpack_Sitemap_Buffer_Video
+ * extends the Jetpack_Sitemap_Buffer class to represent the single video sitemap
+ * buffer.
+ *
+ * @since 5.3.0
+ * @package Jetpack
+ */
+
+/**
+ * A buffer for constructing sitemap video xml files for users without libxml support.
+ *
+ * @since 5.3.0
+ */
+class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer_Fallback {
+
+ protected function get_root_element() {
+ if ( ! isset( $this->root ) ) {
+
+ /**
+ * Filter the XML namespaces included in video sitemaps.
+ *
+ * @module sitemaps
+ *
+ * @since 4.8.0
+ *
+ * @param array $namespaces Associative array with namespaces and namespace URIs.
+ */
+ $namespaces = apply_filters(
+ 'jetpack_sitemap_video_ns',
+ array(
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
+ 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
+ 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
+ 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1',
+ )
+ );
+
+ $video_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'video-sitemap.xsl' );
+ $jetpack_version = JETPACK__VERSION;
+
+ $this->root = array(
+ "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL
+ . "<?xml-stylesheet type='text/xsl' href='{$video_sitemap_xsl_url}'?>" . PHP_EOL
+ . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>',
+ '</urlset>'
+ );
+
+ $this->byte_capacity -= strlen( join( '', $this->root ) );
+ }
+
+ return $this->root;
+ }
+}