sitemap-buffer-fallback.php
4 years ago
sitemap-buffer-image-fallback.php
4 years ago
sitemap-buffer-image.php
3 years ago
sitemap-buffer-master-fallback.php
4 years ago
sitemap-buffer-master.php
3 years ago
sitemap-buffer-news-fallback.php
4 years ago
sitemap-buffer-news.php
3 years ago
sitemap-buffer-page-fallback.php
4 years ago
sitemap-buffer-page.php
3 years ago
sitemap-buffer-video-fallback.php
4 years ago
sitemap-buffer-video.php
3 years ago
sitemap-buffer.php
4 years ago
sitemap-builder.php
3 years ago
sitemap-constants.php
4 years ago
sitemap-finder.php
4 years ago
sitemap-librarian.php
4 years ago
sitemap-logger.php
4 years ago
sitemap-state.php
4 years ago
sitemap-stylist.php
4 years ago
sitemaps.php
5 years ago
sitemap-buffer-video-fallback.php
60 lines
| 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_Video |
| 6 | * extends the Jetpack_Sitemap_Buffer class to represent the single video sitemap |
| 7 | * buffer. |
| 8 | * |
| 9 | * @since 5.3.0 |
| 10 | * @package automattic/jetpack |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * A buffer for constructing sitemap video xml files for users without libxml support. |
| 15 | * |
| 16 | * @since 5.3.0 |
| 17 | */ |
| 18 | class Jetpack_Sitemap_Buffer_Video extends Jetpack_Sitemap_Buffer_Fallback { |
| 19 | /** |
| 20 | * Returns a DOM element that contains all video sitemap elements. |
| 21 | */ |
| 22 | protected function get_root_element() { |
| 23 | if ( ! isset( $this->root ) ) { |
| 24 | |
| 25 | /** |
| 26 | * Filter the XML namespaces included in video sitemaps. |
| 27 | * |
| 28 | * @module sitemaps |
| 29 | * |
| 30 | * @since 4.8.0 |
| 31 | * |
| 32 | * @param array $namespaces Associative array with namespaces and namespace URIs. |
| 33 | */ |
| 34 | $namespaces = apply_filters( |
| 35 | 'jetpack_sitemap_video_ns', |
| 36 | array( |
| 37 | 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
| 38 | 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', |
| 39 | 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', |
| 40 | 'xmlns:video' => 'http://www.google.com/schemas/sitemap-video/1.1', |
| 41 | ) |
| 42 | ); |
| 43 | |
| 44 | $video_sitemap_xsl_url = $this->finder->construct_sitemap_url( 'video-sitemap.xsl' ); |
| 45 | $jetpack_version = JETPACK__VERSION; |
| 46 | |
| 47 | $this->root = array( |
| 48 | "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL |
| 49 | . "<?xml-stylesheet type='text/xsl' href='{$video_sitemap_xsl_url}'?>" . PHP_EOL |
| 50 | . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>', |
| 51 | '</urlset>', |
| 52 | ); |
| 53 | |
| 54 | $this->byte_capacity -= strlen( join( '', $this->root ) ); |
| 55 | } |
| 56 | |
| 57 | return $this->root; |
| 58 | } |
| 59 | } |
| 60 |