<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
// phpcs:disable Generic.Classes.DuplicateClassName.Found -- sitemap-builder.php will require correct class file.
* 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
* @package automattic/jetpack
if ( ! defined( 'ABSPATH' ) ) {
* A buffer for constructing sitemap video xml files for users without libxml support.
* @phan-suppress PhanRedefinedClassReference -- Don't conflict with real version.
class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer_Fallback {
// @phan-suppress-previous-line UnusedSuppression -- It's used.
* Returns a DOM element that contains all video sitemap elements.
protected function get_root_element() {
if ( ! isset( $this->root ) ) {
* Filter the XML namespaces included in video sitemaps.
* @param array $namespaces Associative array with namespaces and namespace URIs.
$namespaces = apply_filters(
'jetpack_sitemap_video_ns',
'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;
"<!-- 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 ) . '>',
$this->byte_capacity -= strlen( implode( '', $this->root ) );