PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 14.9.2
Jetpack – WP Security, Backup, Speed, & Growth v14.9.2
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 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7.3.0.1 7.3.1 7.3.1.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4 7.4.1 7.4.2 7.4.3 7.4.4 7.4.5 7.5 7.5.0.1 7.5.1 7.5.2 7.5.3 7.5.4 7.5.5 7.5.6 7.5.7 7.6 7.6.1 7.6.2 7.6.3 7.6.4 7.7 7.7.1 7.7.2 7.7.3 7.7.4 7.7.5 7.7.6 7.8 7.8.1 7.8.2 7.8.3 7.8.4 7.9 7.9.1 7.9.2 7.9.3 7.9.4 8.0 8.0.1 8.0.2 8.0.3 8.1 8.1.1 8.1.2 8.1.3 8.1.4 8.2 8.2.0.1 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3 8.3.1 8.3.2 8.3.3 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.5 8.5.1 8.5.2 8.5.3 8.6 8.6.1 8.6.2 8.6.3 8.6.4 8.7 8.7.0.1 8.7.1 8.7.2 8.7.3 8.7.4 8.8 8.8.1 8.8.2 8.8.3 8.8.4 8.8.5 8.9 8.9.1 8.9.2 8.9.3 8.9.4 9.0 9.0.1 9.0.2 9.0.3 9.0.4 9.0.5 9.1 9.1.1 9.1.2 9.1.3 9.2 9.2.1 9.2.2 9.2.3 9.2.4 9.3 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.4 9.4.1 9.4.2 9.4.3 9.4.4 9.5 9.5.1 9.5.2 9.5.3 9.5.4 9.5.5 9.6 9.6.1 9.6.2 9.6.3 9.6.4 9.7 9.7.1 9.7.2 15.7-beta.2 9.7.3 15.7.1 9.8 15.8-a.1 9.8.1 15.8-a.3 9.8.2 2.0.9 9.8.3 2.1.7 9.9 2.2.10 9.9.1 2.3.10 9.9.2 2.4.7 9.9.3 2.5.5 2.6.6 2.7.5 2.8.5 2.9.6 3.0.6 3.1.5 3.2.5 3.3.6 3.4.6 3.5.6 3.6.4 3.7.5 3.8.5 3.9.10 4.0.7 4.1.4 4.2.5 4.3.5 4.4.5 4.5.3 4.6.3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / sitemaps / sitemap-stylist.php
jetpack / modules / sitemaps Last commit date
sitemap-buffer-factory.php 1 year ago sitemap-buffer-fallback.php 2 years ago sitemap-buffer-image-fallback.php 2 years ago sitemap-buffer-image-xmlwriter.php 1 year ago sitemap-buffer-image.php 4 years ago sitemap-buffer-master-fallback.php 2 years ago sitemap-buffer-master-xmlwriter.php 1 year ago sitemap-buffer-master.php 4 years ago sitemap-buffer-news-fallback.php 2 years ago sitemap-buffer-news-xmlwriter.php 1 year ago sitemap-buffer-news.php 4 years ago sitemap-buffer-page-fallback.php 2 years ago sitemap-buffer-page-xmlwriter.php 1 year ago sitemap-buffer-page.php 4 years ago sitemap-buffer-video-fallback.php 1 year ago sitemap-buffer-video-xmlwriter.php 1 year ago sitemap-buffer-video.php 4 years ago sitemap-buffer-xmlwriter.php 1 year ago sitemap-buffer.php 1 year ago sitemap-builder.php 1 year ago sitemap-constants.php 1 year ago sitemap-finder.php 2 years ago sitemap-librarian.php 1 year ago sitemap-logger.php 1 year ago sitemap-state.php 2 years ago sitemap-stylist.php 2 years ago sitemaps.php 1 year ago
sitemap-stylist.php
788 lines
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * The XSL used to style sitemaps is essentially a bunch of
4 * static strings. This class handles the construction of
5 * those strings.
6 *
7 * @package automattic/jetpack
8 * @since 4.8.0
9 */
10
11 /**
12 * Builds the XSL files required by Jetpack_Sitemap_Manager.
13 *
14 * @since 4.8.0
15 */
16 class Jetpack_Sitemap_Stylist {
17
18 /**
19 * Convert named entities, strip all HTML except anchor tags,
20 * and interpolate with vsprintf. This is a helper function
21 * for all the internationalized UI strings in this class
22 * which have to include URLs.
23 *
24 * Note that $url_array should be indexed by integers like so:
25 *
26 * array(
27 * 1 => 'example.com',
28 * 2 => 'example.org',
29 * );
30 *
31 * Then '%1$s' in the format string will substitute 'example.com'
32 * and '%2$s' will substitute 'example.org'.
33 *
34 * @access private
35 * @since 4.8.0
36 * @link https://php.net/manual/en/function.vsprintf.php Format string documentation.
37 *
38 * @param string $format A vsprintf-style format string to be sanitized.
39 * @param array $url_array The string substitution array to be passed to vsprintf.
40 *
41 * @return string The sanitized string.
42 */
43 private static function sanitize_with_links( $format, $url_array ) {
44 return vsprintf(
45 wp_kses(
46 ent2ncr( $format ),
47 array(
48 'a' => array(
49 'href' => true,
50 'title' => true,
51 ),
52 )
53 ),
54 $url_array
55 );
56 }
57
58 /**
59 * Returns the xsl of a sitemap xml file as a string.
60 *
61 * @access public
62 * @since 4.8.0
63 *
64 * @return string The contents of the xsl file.
65 */
66 public static function sitemap_xsl() {
67 $title = esc_html( ent2ncr( __( 'XML Sitemap', 'jetpack' ) ) );
68 $header_url = esc_html( ent2ncr( __( 'URL', 'jetpack' ) ) );
69 $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
70
71 $description = self::sanitize_with_links(
72 /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
73 __(
74 'This is an XML Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
75 'jetpack'
76 ),
77 array(
78 1 => 'https://jetpack.com/',
79 2 => 'https://www.google.com/',
80 3 => 'https://www.bing.com/',
81 )
82 );
83
84 $more_info = self::sanitize_with_links(
85 /* translators: %1$s: sitemaps.org URL. */
86 __(
87 'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
88 'jetpack'
89 ),
90 array(
91 1 => 'https://sitemaps.org',
92 )
93 );
94
95 $generated_by = self::sanitize_with_links(
96 /* translators: %s: jetpack.com URL. */
97 __(
98 'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
99 'jetpack'
100 ),
101 array(
102 1 => 'https://jetpack.com',
103 )
104 );
105
106 $css = self::sitemap_xsl_css();
107
108 return <<<XSL
109 <?xml version='1.0' encoding='UTF-8'?>
110 <xsl:stylesheet version='2.0'
111 xmlns:html='http://www.w3.org/TR/REC-html40'
112 xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
113 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
114 <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
115 <xsl:template match="/">
116 <html xmlns="http://www.w3.org/1999/xhtml">
117 <head>
118 <title>$title</title>
119 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
120 <style type='text/css'>
121 $css
122 </style>
123 </head>
124 <body>
125 <div id='description'>
126 <h1>$title</h1>
127 <p>$description</p>
128 <p>$more_info</p>
129 </div>
130 <div id='content'>
131 <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
132 <table>
133 <tr>
134 <th>#</th>
135 <th>$header_url</th>
136 <th>$header_lastmod</th>
137 </tr>
138 <xsl:for-each select="sitemap:urlset/sitemap:url">
139 <tr>
140 <xsl:choose>
141 <xsl:when test='position() mod 2 != 1'>
142 <xsl:attribute name="class">odd</xsl:attribute>
143 </xsl:when>
144 </xsl:choose>
145 <td>
146 <xsl:value-of select = "position()" />
147 </td>
148 <td>
149 <xsl:variable name='itemURL'>
150 <xsl:value-of select='sitemap:loc'/>
151 </xsl:variable>
152 <a href='{\$itemURL}'>
153 <xsl:value-of select='sitemap:loc'/>
154 </a>
155 </td>
156 <td>
157 <xsl:value-of select='sitemap:lastmod'/>
158 </td>
159 </tr>
160 </xsl:for-each>
161 </table>
162 </div>
163 <div id='footer'>
164 <p>$generated_by</p>
165 </div>
166 </body>
167 </html>
168 </xsl:template>
169 </xsl:stylesheet>\n
170 XSL;
171 }
172
173 /**
174 * Returns the xsl of a sitemap index xml file as a string.
175 *
176 * @access public
177 * @since 4.8.0
178 *
179 * @return string The contents of the xsl file.
180 */
181 public static function sitemap_index_xsl() {
182 $title = esc_html( ent2ncr( __( 'XML Sitemap Index', 'jetpack' ) ) );
183 $header_url = esc_html( ent2ncr( __( 'Sitemap URL', 'jetpack' ) ) );
184 $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
185
186 $description = self::sanitize_with_links(
187 /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
188 __(
189 'This is an XML Sitemap Index generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
190 'jetpack'
191 ),
192 array(
193 1 => 'https://jetpack.com/',
194 2 => 'https://www.google.com/',
195 3 => 'https://www.bing.com/',
196 )
197 );
198
199 if ( current_user_can( 'manage_options' ) ) {
200 $next = human_time_diff( wp_next_scheduled( 'jp_sitemap_cron_hook' ) );
201 /* translators: %s is a human_time_diff until next sitemap generation. */
202 $no_nodes_warning = sprintf( __( 'No sitemap found. The system will try to build it again in %s.', 'jetpack' ), $next );
203 } else {
204 $no_nodes_warning = '';
205 }
206
207 $more_info = self::sanitize_with_links(
208 /* translators: %1$s: sitemaps.org URL. */
209 __(
210 'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
211 'jetpack'
212 ),
213 array(
214 1 => 'https://sitemaps.org',
215 )
216 );
217
218 $generated_by = self::sanitize_with_links(
219 /* translators: %s: jetpack.com URL. */
220 __(
221 'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
222 'jetpack'
223 ),
224 array(
225 1 => 'https://jetpack.com',
226 )
227 );
228
229 $css = self::sitemap_xsl_css();
230
231 return <<<XSL
232 <?xml version='1.0' encoding='UTF-8'?>
233 <xsl:stylesheet version='2.0'
234 xmlns:html='http://www.w3.org/TR/REC-html40'
235 xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
236 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
237 <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
238 <xsl:template match="/">
239 <html xmlns="http://www.w3.org/1999/xhtml">
240 <head>
241 <title>$title</title>
242 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
243 <style type='text/css'>
244 $css
245 </style>
246 </head>
247 <body>
248 <div id='description'>
249 <h1>$title</h1>
250 <xsl:choose>
251 <xsl:when test='not(sitemap:sitemapindex/sitemap:sitemap)'>
252 <p><strong>$no_nodes_warning</strong></p>
253 </xsl:when>
254 </xsl:choose>
255 <p>$description</p>
256 <p>$more_info</p>
257 </div>
258 <div id='content'>
259 <table>
260 <tr>
261 <th>#</th>
262 <th>$header_url</th>
263 <th>$header_lastmod</th>
264 </tr>
265 <xsl:for-each select='sitemap:sitemapindex/sitemap:sitemap'>
266 <tr>
267 <xsl:choose>
268 <xsl:when test='position() mod 2 != 1'>
269 <xsl:attribute name="class">odd</xsl:attribute>
270 </xsl:when>
271 </xsl:choose>
272 <td>
273 <xsl:value-of select = "position()" />
274 </td>
275 <td>
276 <xsl:variable name='itemURL'>
277 <xsl:value-of select='sitemap:loc'/>
278 </xsl:variable>
279 <a href='{\$itemURL}'>
280 <xsl:value-of select='sitemap:loc'/>
281 </a>
282 </td>
283 <td>
284 <xsl:value-of select='sitemap:lastmod'/>
285 </td>
286 </tr>
287 </xsl:for-each>
288 </table>
289 </div>
290 <div id='footer'>
291 <p>$generated_by</p>
292 </div>
293 </body>
294 </html>
295 </xsl:template>
296 </xsl:stylesheet>\n
297 XSL;
298 }
299
300 /**
301 * Returns the xsl of an image sitemap xml file as a string.
302 *
303 * @access public
304 * @since 4.8.0
305 *
306 * @return string The contents of the xsl file.
307 */
308 public static function image_sitemap_xsl() {
309 $title = esc_html( ent2ncr( __( 'XML Image Sitemap', 'jetpack' ) ) );
310 $header_url = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) );
311 $header_image_url = esc_html( ent2ncr( __( 'Image URL', 'jetpack' ) ) );
312 $header_thumbnail = esc_html( ent2ncr( __( 'Thumbnail', 'jetpack' ) ) );
313 $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
314
315 $description = self::sanitize_with_links(
316 /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
317 __(
318 'This is an XML Image Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
319 'jetpack'
320 ),
321 array(
322 1 => 'https://jetpack.com/',
323 2 => 'https://www.google.com/',
324 3 => 'https://www.bing.com/',
325 )
326 );
327
328 $more_info = self::sanitize_with_links(
329 /* translators: %1$s: sitemaps.org URL. */
330 __(
331 'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
332 'jetpack'
333 ),
334 array(
335 1 => 'https://sitemaps.org',
336 )
337 );
338
339 $generated_by = self::sanitize_with_links(
340 /* translators: %s: jetpack.com URL. */
341 __(
342 'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
343 'jetpack'
344 ),
345 array(
346 1 => 'https://jetpack.com',
347 )
348 );
349
350 $css = self::sitemap_xsl_css();
351
352 return <<<XSL
353 <?xml version='1.0' encoding='UTF-8'?>
354 <xsl:stylesheet version='2.0'
355 xmlns:html='http://www.w3.org/TR/REC-html40'
356 xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
357 xmlns:image='http://www.google.com/schemas/sitemap-image/1.1'
358 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
359 <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
360 <xsl:template match="/">
361 <html xmlns="http://www.w3.org/1999/xhtml">
362 <head>
363 <title>$title</title>
364 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
365 <style type='text/css'>
366 $css
367 </style>
368 </head>
369 <body>
370 <div id='description'>
371 <h1>$title</h1>
372 <p>$description</p>
373 <p>$more_info</p>
374 </div>
375 <div id='content'>
376 <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
377 <table>
378 <tr>
379 <th>#</th>
380 <th>$header_url</th>
381 <th>$header_image_url</th>
382 <th>$header_lastmod</th>
383 <th>$header_thumbnail</th>
384 </tr>
385 <xsl:for-each select="sitemap:urlset/sitemap:url">
386 <tr>
387 <xsl:choose>
388 <xsl:when test='position() mod 2 != 1'>
389 <xsl:attribute name="class">odd</xsl:attribute>
390 </xsl:when>
391 </xsl:choose>
392 <td>
393 <xsl:value-of select = "position()" />
394 </td>
395 <td>
396 <xsl:variable name='pageURL'>
397 <xsl:value-of select='sitemap:loc'/>
398 </xsl:variable>
399 <a href='{\$pageURL}'>
400 <xsl:value-of select='sitemap:loc'/>
401 </a>
402 </td>
403 <xsl:variable name='itemURL'>
404 <xsl:value-of select='image:image/image:loc'/>
405 </xsl:variable>
406 <td>
407 <a href='{\$itemURL}'>
408 <xsl:value-of select='image:image/image:loc'/>
409 </a>
410 </td>
411 <td>
412 <xsl:value-of select='sitemap:lastmod'/>
413 </td>
414 <td>
415 <a href='{\$itemURL}'>
416 <img class='thumbnail' src='{\$itemURL}'/>
417 </a>
418 </td>
419 </tr>
420 </xsl:for-each>
421 </table>
422 </div>
423 <div id='footer'>
424 <p>$generated_by</p>
425 </div>
426 </body>
427 </html>
428 </xsl:template>
429 </xsl:stylesheet>\n
430 XSL;
431 }
432
433 /**
434 * Returns the xsl of a video sitemap xml file as a string.
435 *
436 * @access public
437 * @since 4.8.0
438 *
439 * @return string The contents of the xsl file.
440 */
441 public static function video_sitemap_xsl() {
442 $title = esc_html( ent2ncr( __( 'XML Video Sitemap', 'jetpack' ) ) );
443 $header_url = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) );
444 $header_image_url = esc_html( ent2ncr( __( 'Video URL', 'jetpack' ) ) );
445 $header_thumbnail = esc_html( ent2ncr( __( 'Thumbnail', 'jetpack' ) ) );
446 $header_title = esc_html( ent2ncr( __( 'Title', 'jetpack' ) ) );
447 $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
448 $header_description = esc_html( ent2ncr( __( 'Description', 'jetpack' ) ) );
449
450 $description = self::sanitize_with_links(
451 /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
452 __(
453 'This is an XML Video Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
454 'jetpack'
455 ),
456 array(
457 1 => 'https://jetpack.com/',
458 2 => 'https://www.google.com/',
459 3 => 'https://www.bing.com/',
460 )
461 );
462
463 $more_info = self::sanitize_with_links(
464 /* translators: %1$s: sitemaps.org URL. */
465 __(
466 'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
467 'jetpack'
468 ),
469 array(
470 1 => 'https://sitemaps.org',
471 )
472 );
473
474 $generated_by = self::sanitize_with_links(
475 /* translators: %s: jetpack.com URL. */
476 __(
477 'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
478 'jetpack'
479 ),
480 array(
481 1 => 'https://jetpack.com',
482 )
483 );
484
485 $css = self::sitemap_xsl_css();
486
487 return <<<XSL
488 <?xml version='1.0' encoding='UTF-8'?>
489 <xsl:stylesheet version='2.0'
490 xmlns:html='http://www.w3.org/TR/REC-html40'
491 xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
492 xmlns:video='http://www.google.com/schemas/sitemap-video/1.1'
493 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
494 <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
495 <xsl:template match="/">
496 <html xmlns="http://www.w3.org/1999/xhtml">
497 <head>
498 <title>$title</title>
499 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
500 <style type='text/css'>
501 $css
502 </style>
503 </head>
504 <body>
505 <div id='description'>
506 <h1>$title</h1>
507 <p>$description</p>
508 <p>$more_info</p>
509 </div>
510 <div id='content'>
511 <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
512 <table>
513 <tr>
514 <th>#</th>
515 <th>$header_url</th>
516 <th>$header_image_url</th>
517 <th>$header_title</th>
518 <th>$header_description</th>
519 <th>$header_lastmod</th>
520 <th>$header_thumbnail</th>
521 </tr>
522 <xsl:for-each select="sitemap:urlset/sitemap:url">
523 <tr>
524 <xsl:choose>
525 <xsl:when test='position() mod 2 != 1'>
526 <xsl:attribute name="class">odd</xsl:attribute>
527 </xsl:when>
528 </xsl:choose>
529 <td>
530 <xsl:value-of select = "position()" />
531 </td>
532 <td>
533 <xsl:variable name='pageURL'>
534 <xsl:value-of select='sitemap:loc'/>
535 </xsl:variable>
536 <a href='{\$pageURL}'>
537 <xsl:value-of select='sitemap:loc'/>
538 </a>
539 </td>
540 <xsl:variable name='itemURL'>
541 <xsl:value-of select='video:video/video:content_loc'/>
542 </xsl:variable>
543 <td>
544 <a href='{\$itemURL}'>
545 <xsl:value-of select='video:video/video:content_loc'/>
546 </a>
547 </td>
548 <td>
549 <xsl:value-of select='video:video/video:title'/>
550 </td>
551 <td>
552 <xsl:value-of select='video:video/video:description' disable-output-escaping='yes'/>
553 </td>
554 <td>
555 <xsl:value-of select='sitemap:lastmod'/>
556 </td>
557 <td>
558 <xsl:variable name='thumbURL'>
559 <xsl:value-of select='video:video/video:thumbnail_loc'/>
560 </xsl:variable>
561 <a href='{\$thumbURL}'>
562 <img class='thumbnail' src='{\$thumbURL}'/>
563 </a>
564 </td>
565 </tr>
566 </xsl:for-each>
567 </table>
568 </div>
569 <div id='footer'>
570 <p>$generated_by</p>
571 </div>
572 </body>
573 </html>
574 </xsl:template>
575 </xsl:stylesheet>\n
576 XSL;
577 }
578
579 /**
580 * Returns the xsl of a news sitemap xml file as a string.
581 *
582 * @access public
583 * @since 4.8.0
584 *
585 * @return string The contents of the xsl file.
586 */
587 public static function news_sitemap_xsl() {
588 $title = esc_html( ent2ncr( __( 'XML News Sitemap', 'jetpack' ) ) );
589 $header_url = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) );
590 $header_title = esc_html( ent2ncr( __( 'Title', 'jetpack' ) ) );
591 $header_pubdate = esc_html( ent2ncr( __( 'Publication Date', 'jetpack' ) ) );
592
593 $description = self::sanitize_with_links(
594 /* translators: %1$s: jetpack.com URL. %2$s: google.com URL. %3$s: bing.com URL. */
595 __(
596 'This is an XML News Sitemap generated by <a href="%1$s" rel="noopener noreferrer" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" rel="noopener noreferrer" target="_blank">Google</a> or <a href="%3$s" rel="noopener noreferrer" target="_blank">Bing</a>.',
597 'jetpack'
598 ),
599 array(
600 1 => 'https://jetpack.com/',
601 2 => 'https://www.google.com/',
602 3 => 'https://www.bing.com/',
603 )
604 );
605
606 $more_info = self::sanitize_with_links(
607 /* translators: %1$s: sitemaps.org URL. */
608 __(
609 'You can find more information on XML sitemaps at <a href="%1$s" rel="noopener noreferrer" target="_blank">sitemaps.org</a>',
610 'jetpack'
611 ),
612 array(
613 1 => 'https://sitemaps.org',
614 )
615 );
616
617 $generated_by = self::sanitize_with_links(
618 /* translators: %s: jetpack.com URL. */
619 __(
620 'Generated by <a href="%s" rel="noopener noreferrer" target="_blank">Jetpack for WordPress</a>',
621 'jetpack'
622 ),
623 array(
624 1 => 'https://jetpack.com',
625 )
626 );
627
628 $css = self::sitemap_xsl_css();
629
630 return <<<XSL
631 <?xml version='1.0' encoding='UTF-8'?>
632 <xsl:stylesheet version='2.0'
633 xmlns:html='http://www.w3.org/TR/REC-html40'
634 xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
635 xmlns:news='http://www.google.com/schemas/sitemap-news/0.9'
636 xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
637 <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
638 <xsl:template match="/">
639 <html xmlns="http://www.w3.org/1999/xhtml">
640 <head>
641 <title>$title</title>
642 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
643 <style type='text/css'>
644 $css
645 </style>
646 </head>
647 <body>
648 <div id='description'>
649 <h1>$title</h1>
650 <p>$description</p>
651 <p>$more_info</p>
652 </div>
653 <div id='content'>
654 <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
655 <table>
656 <tr>
657 <th>#</th>
658 <th>$header_url</th>
659 <th>$header_title</th>
660 <th>$header_pubdate</th>
661 </tr>
662 <xsl:for-each select="sitemap:urlset/sitemap:url">
663 <tr>
664 <xsl:choose>
665 <xsl:when test='position() mod 2 != 1'>
666 <xsl:attribute name="class">odd</xsl:attribute>
667 </xsl:when>
668 </xsl:choose>
669 <td>
670 <xsl:value-of select = "position()" />
671 </td>
672 <xsl:variable name='pageURL'>
673 <xsl:value-of select='sitemap:loc'/>
674 </xsl:variable>
675 <td>
676 <a href='{\$pageURL}'>
677 <xsl:value-of select='sitemap:loc'/>
678 </a>
679 </td>
680 <td>
681 <a href='{\$pageURL}'>
682 <xsl:value-of select='news:news/news:title'/>
683 </a>
684 </td>
685 <td>
686 <xsl:value-of select='news:news/news:publication_date'/>
687 </td>
688 </tr>
689 </xsl:for-each>
690 </table>
691 </div>
692 <div id='footer'>
693 <p>$generated_by</p>
694 </div>
695 </body>
696 </html>
697 </xsl:template>
698 </xsl:stylesheet>\n
699 XSL;
700 }
701
702 /**
703 * The CSS to be included in sitemap xsl stylesheets;
704 * factored out for uniformity.
705 *
706 * @access public
707 * @since 4.8.0
708 *
709 * @return string The CSS.
710 */
711 public static function sitemap_xsl_css() {
712 return <<<CSS
713 body {
714 font: 14px 'Open Sans', Helvetica, Arial, sans-serif;
715 margin: 0;
716 }
717
718 a {
719 color: #3498db;
720 text-decoration: none;
721 }
722
723 h1 {
724 margin: 0;
725 }
726
727 #description {
728 background-color: #f0f2eb;
729 color: #000;
730 padding: 30px 30px 20px;
731 }
732
733 #description a {
734 color: #008710;
735 }
736
737 #content {
738 padding: 10px 30px 30px;
739 background: #fff;
740 }
741
742 a:hover {
743 border-bottom: 1px solid;
744 }
745
746 th, td {
747 font-size: 12px;
748 }
749
750 th {
751 text-align: left;
752 border-bottom: 1px solid #ccc;
753 }
754
755 th, td {
756 padding: 10px 15px;
757 }
758
759 .odd {
760 background: linear-gradient( 159.87deg, #f6f6f4 7.24%, #f7f4ea 64.73%, #ddedd5 116.53% );
761 }
762
763 #footer {
764 margin: 20px 30px;
765 font-size: 12px;
766 color: #999;
767 }
768
769 #footer a {
770 color: inherit;
771 }
772
773 #description a, #footer a {
774 border-bottom: 1px solid;
775 }
776
777 #description a:hover, #footer a:hover {
778 border-bottom: none;
779 }
780
781 img {
782 max-height: 100px;
783 max-width: 100px;
784 }
785 CSS;
786 }
787 }
788