@@ 289-419 (lines=131) @@ | ||
286 | * |
|
287 | * @return string The contents of the xsl file. |
|
288 | */ |
|
289 | public static function image_sitemap_xsl() { |
|
290 | $title = esc_html( ent2ncr( __( 'XML Image Sitemap', 'jetpack' ) ) ); |
|
291 | $header_url = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) ); |
|
292 | $header_image_url = esc_html( ent2ncr( __( 'Image URL', 'jetpack' ) ) ); |
|
293 | $header_thumbnail = esc_html( ent2ncr( __( 'Thumbnail', 'jetpack' ) ) ); |
|
294 | $header_title = esc_html( ent2ncr( __( 'Title', 'jetpack' ) ) ); |
|
295 | $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) ); |
|
296 | $header_caption = esc_html( ent2ncr( __( 'Caption', 'jetpack' ) ) ); |
|
297 | ||
298 | $description = self::sanitize_with_links( |
|
299 | __( |
|
300 | 'This is an XML Image Sitemap generated by <a href="%1$s" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" target="_blank">Google</a> or <a href="%3$s" target="_blank">Bing</a>.', |
|
301 | 'jetpack' |
|
302 | ), |
|
303 | array( |
|
304 | 1 => 'http://jetpack.com/', |
|
305 | 2 => 'https://www.google.com/', |
|
306 | 3 => 'https://www.bing.com/', |
|
307 | ) |
|
308 | ); |
|
309 | ||
310 | $more_info = self::sanitize_with_links( |
|
311 | __( |
|
312 | 'You can find more information on XML sitemaps at <a href="%1$s" target="_blank">sitemaps.org</a>', |
|
313 | 'jetpack' |
|
314 | ), |
|
315 | array( |
|
316 | 1 => 'http://sitemaps.org', |
|
317 | ) |
|
318 | ); |
|
319 | ||
320 | $generated_by = self::sanitize_with_links( |
|
321 | __( |
|
322 | 'Generated by <a href="%s" target="_blank">Jetpack for WordPress</a>', |
|
323 | 'jetpack' |
|
324 | ), |
|
325 | array( |
|
326 | 1 => 'https://jetpack.com', |
|
327 | ) |
|
328 | ); |
|
329 | ||
330 | $css = self::sitemap_xsl_css(); |
|
331 | ||
332 | return <<<XSL |
|
333 | <?xml version='1.0' encoding='UTF-8'?> |
|
334 | <xsl:stylesheet version='2.0' |
|
335 | xmlns:html='http://www.w3.org/TR/REC-html40' |
|
336 | xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9' |
|
337 | xmlns:image='http://www.google.com/schemas/sitemap-image/1.1' |
|
338 | xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
|
339 | <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> |
|
340 | <xsl:template match="/"> |
|
341 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
342 | <head> |
|
343 | <title>$title</title> |
|
344 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> |
|
345 | <style type='text/css'> |
|
346 | $css |
|
347 | </style> |
|
348 | </head> |
|
349 | <body> |
|
350 | <div id='description'> |
|
351 | <h1>$title</h1> |
|
352 | <p>$description</p> |
|
353 | <p>$more_info</p> |
|
354 | </div> |
|
355 | <div id='content'> |
|
356 | <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> --> |
|
357 | <table> |
|
358 | <tr> |
|
359 | <th>#</th> |
|
360 | <th>$header_url</th> |
|
361 | <th>$header_image_url</th> |
|
362 | <th>$header_title</th> |
|
363 | <th>$header_caption</th> |
|
364 | <th>$header_lastmod</th> |
|
365 | <th>$header_thumbnail</th> |
|
366 | </tr> |
|
367 | <xsl:for-each select="sitemap:urlset/sitemap:url"> |
|
368 | <tr> |
|
369 | <xsl:choose> |
|
370 | <xsl:when test='position() mod 2 != 1'> |
|
371 | <xsl:attribute name="class">odd</xsl:attribute> |
|
372 | </xsl:when> |
|
373 | </xsl:choose> |
|
374 | <td> |
|
375 | <xsl:value-of select = "position()" /> |
|
376 | </td> |
|
377 | <td> |
|
378 | <xsl:variable name='pageURL'> |
|
379 | <xsl:value-of select='sitemap:loc'/> |
|
380 | </xsl:variable> |
|
381 | <a href='{\$pageURL}'> |
|
382 | <xsl:value-of select='sitemap:loc'/> |
|
383 | </a> |
|
384 | </td> |
|
385 | <xsl:variable name='itemURL'> |
|
386 | <xsl:value-of select='image:image/image:loc'/> |
|
387 | </xsl:variable> |
|
388 | <td> |
|
389 | <a href='{\$itemURL}'> |
|
390 | <xsl:value-of select='image:image/image:loc'/> |
|
391 | </a> |
|
392 | </td> |
|
393 | <td> |
|
394 | <xsl:value-of select='image:image/image:title'/> |
|
395 | </td> |
|
396 | <td> |
|
397 | <xsl:value-of select='image:image/image:caption'/> |
|
398 | </td> |
|
399 | <td> |
|
400 | <xsl:value-of select='sitemap:lastmod'/> |
|
401 | </td> |
|
402 | <td> |
|
403 | <a href='{\$itemURL}'> |
|
404 | <img class='thumbnail' src='{\$itemURL}'/> |
|
405 | </a> |
|
406 | </td> |
|
407 | </tr> |
|
408 | </xsl:for-each> |
|
409 | </table> |
|
410 | </div> |
|
411 | <div id='footer'> |
|
412 | <p>$generated_by</p> |
|
413 | </div> |
|
414 | </body> |
|
415 | </html> |
|
416 | </xsl:template> |
|
417 | </xsl:stylesheet>\n |
|
418 | XSL; |
|
419 | } |
|
420 | ||
421 | /** |
|
422 | * Returns the xsl of a video sitemap xml file as a string. |
|
@@ 429-562 (lines=134) @@ | ||
426 | * |
|
427 | * @return string The contents of the xsl file. |
|
428 | */ |
|
429 | public static function video_sitemap_xsl() { |
|
430 | $title = esc_html( ent2ncr( __( 'XML Video Sitemap', 'jetpack' ) ) ); |
|
431 | $header_url = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) ); |
|
432 | $header_image_url = esc_html( ent2ncr( __( 'Video URL', 'jetpack' ) ) ); |
|
433 | $header_thumbnail = esc_html( ent2ncr( __( 'Thumbnail', 'jetpack' ) ) ); |
|
434 | $header_title = esc_html( ent2ncr( __( 'Title', 'jetpack' ) ) ); |
|
435 | $header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) ); |
|
436 | $header_description = esc_html( ent2ncr( __( 'Description', 'jetpack' ) ) ); |
|
437 | ||
438 | $description = self::sanitize_with_links( |
|
439 | __( |
|
440 | 'This is an XML Video Sitemap generated by <a href="%1$s" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%2$s" target="_blank">Google</a> or <a href="%3$s" target="_blank">Bing</a>.', |
|
441 | 'jetpack' |
|
442 | ), |
|
443 | array( |
|
444 | 1 => 'http://jetpack.com/', |
|
445 | 2 => 'https://www.google.com/', |
|
446 | 3 => 'https://www.bing.com/', |
|
447 | ) |
|
448 | ); |
|
449 | ||
450 | $more_info = self::sanitize_with_links( |
|
451 | __( |
|
452 | 'You can find more information on XML sitemaps at <a href="%1$s" target="_blank">sitemaps.org</a>', |
|
453 | 'jetpack' |
|
454 | ), |
|
455 | array( |
|
456 | 1 => 'http://sitemaps.org', |
|
457 | ) |
|
458 | ); |
|
459 | ||
460 | $generated_by = self::sanitize_with_links( |
|
461 | __( |
|
462 | 'Generated by <a href="%s" target="_blank">Jetpack for WordPress</a>', |
|
463 | 'jetpack' |
|
464 | ), |
|
465 | array( |
|
466 | 1 => 'https://jetpack.com', |
|
467 | ) |
|
468 | ); |
|
469 | ||
470 | $css = self::sitemap_xsl_css(); |
|
471 | ||
472 | return <<<XSL |
|
473 | <?xml version='1.0' encoding='UTF-8'?> |
|
474 | <xsl:stylesheet version='2.0' |
|
475 | xmlns:html='http://www.w3.org/TR/REC-html40' |
|
476 | xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9' |
|
477 | xmlns:video='http://www.google.com/schemas/sitemap-video/1.1' |
|
478 | xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> |
|
479 | <xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/> |
|
480 | <xsl:template match="/"> |
|
481 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
482 | <head> |
|
483 | <title>$title</title> |
|
484 | <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/> |
|
485 | <style type='text/css'> |
|
486 | $css |
|
487 | </style> |
|
488 | </head> |
|
489 | <body> |
|
490 | <div id='description'> |
|
491 | <h1>$title</h1> |
|
492 | <p>$description</p> |
|
493 | <p>$more_info</p> |
|
494 | </div> |
|
495 | <div id='content'> |
|
496 | <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> --> |
|
497 | <table> |
|
498 | <tr> |
|
499 | <th>#</th> |
|
500 | <th>$header_url</th> |
|
501 | <th>$header_image_url</th> |
|
502 | <th>$header_title</th> |
|
503 | <th>$header_description</th> |
|
504 | <th>$header_lastmod</th> |
|
505 | <th>$header_thumbnail</th> |
|
506 | </tr> |
|
507 | <xsl:for-each select="sitemap:urlset/sitemap:url"> |
|
508 | <tr> |
|
509 | <xsl:choose> |
|
510 | <xsl:when test='position() mod 2 != 1'> |
|
511 | <xsl:attribute name="class">odd</xsl:attribute> |
|
512 | </xsl:when> |
|
513 | </xsl:choose> |
|
514 | <td> |
|
515 | <xsl:value-of select = "position()" /> |
|
516 | </td> |
|
517 | <td> |
|
518 | <xsl:variable name='pageURL'> |
|
519 | <xsl:value-of select='sitemap:loc'/> |
|
520 | </xsl:variable> |
|
521 | <a href='{\$pageURL}'> |
|
522 | <xsl:value-of select='sitemap:loc'/> |
|
523 | </a> |
|
524 | </td> |
|
525 | <xsl:variable name='itemURL'> |
|
526 | <xsl:value-of select='video:video/video:content_loc'/> |
|
527 | </xsl:variable> |
|
528 | <td> |
|
529 | <a href='{\$itemURL}'> |
|
530 | <xsl:value-of select='video:video/video:content_loc'/> |
|
531 | </a> |
|
532 | </td> |
|
533 | <td> |
|
534 | <xsl:value-of select='video:video/video:title'/> |
|
535 | </td> |
|
536 | <td> |
|
537 | <xsl:value-of select='video:video/video:description'/> |
|
538 | </td> |
|
539 | <td> |
|
540 | <xsl:value-of select='sitemap:lastmod'/> |
|
541 | </td> |
|
542 | <td> |
|
543 | <xsl:variable name='thumbURL'> |
|
544 | <xsl:value-of select='video:video/video:thumbnail_loc'/> |
|
545 | </xsl:variable> |
|
546 | <a href='{\$thumbURL}'> |
|
547 | <img class='thumbnail' src='{\$thumbURL}'/> |
|
548 | </a> |
|
549 | </td> |
|
550 | </tr> |
|
551 | </xsl:for-each> |
|
552 | </table> |
|
553 | </div> |
|
554 | <div id='footer'> |
|
555 | <p>$generated_by</p> |
|
556 | </div> |
|
557 | </body> |
|
558 | </html> |
|
559 | </xsl:template> |
|
560 | </xsl:stylesheet>\n |
|
561 | XSL; |
|
562 | } |
|
563 | ||
564 | /** |
|
565 | * Returns the xsl of a news sitemap xml file as a string. |