summaryrefslogtreecommitdiff
blob: 906f11fbacae1a817acb791da769ed09df3b2b2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
 * XSLT for XML sitemap
 *
 * @module sitemaps
 */

$xsl = '<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
				xmlns:html="http://www.w3.org/TR/REC-html40"
				xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
				xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
				xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
				xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<html xmlns="http://www.w3.org/1999/xhtml">
			<head>
				<title>' . esc_html( ent2ncr( __( 'XML Sitemap', 'jetpack' ) ) ) . '</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
				<style type="text/css">
					body {
						font: 14px "Open Sans", Helvetica, Arial, sans-serif;
						margin: 0;
					}

					a {
						color: #3498db;
						text-decoration: none;
					}

					h1 {
						margin: 0;
					}

					#description {
						background-color: #81a844;
						color: #FFF;
						padding: 30px 30px 20px;
					}

					#description a {
						color: #fff;
					}

					#content {
						padding: 10px 30px 30px;
						background: #fff;
					}

					a:hover {
						border-bottom: 1px solid;
					}

					th, td {
						font-size: 12px;
					}

					th {
						text-align: left;
						border-bottom: 1px solid #ccc;
					}

					th, td {
						padding: 10px 15px;
					}

					.odd {
						background-color: #E7F1D4;
					}

					#footer {
						margin: 20px 30px;
						font-size: 12px;
						color: #999;
					}

					#footer a {
						color: inherit;
					}

					#description a, #footer a {
						border-bottom: 1px solid;
					}
					#description a:hover, #footer a:hover {
						border-bottom: none;
					}
				</style>
			</head>
			<body>
				<div id="description">
					<h1>' . esc_html( ent2ncr( __( 'XML Sitemap', 'jetpack' ) ) ) . '</h1>
					<p>' . wp_kses( sprintf( ent2ncr( __( 'This is an XML Sitemap generated by <a href="%s" target="_blank">Jetpack</a>, meant to be consumed by search engines like <a href="%s" target="_blank">Google</a> or <a href="%s" target="_blank">Bing</a>.', 'jetpack' ), 'http://jetpack.com/', 'https://www.google.com', 'https://www.bing.com/' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) ) . '</p>
					<p>' . wp_kses( sprintf( ent2ncr( __( 'You can find more information on XML sitemaps at <a href="%s" target="_blank">sitemaps.org</a>', 'jetpack' ), 'http://sitemaps.org' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) ) . '</p>
				</div>
				<div id="content">
					<table>
						<tr>
							<th>' . esc_html( ent2ncr( __( 'URL', 'jetpack' ) ) ) . '</th>
							<th>' . esc_html( ent2ncr( __( 'Images', 'jetpack' ) ) ) . '</th>';
if ( empty( $type ) ) :
$xsl .= '					<th>' . esc_html( ent2ncr( __( 'Change Frequency', 'jetpack' ) ) ) . '</th>
							<th>' . esc_html( ent2ncr( __( 'Last Updated', 'jetpack' ) ) ) . '</th>';
endif;
$xsl .= '				</tr>
						<xsl:variable name="lower" select="\'abcdefghijklmnopqrstuvwxyz\'"/>
						<xsl:variable name="upper" select="\'ABCDEFGHIJKLMNOPQRSTUVWXYZ\'"/>
						<xsl:for-each select="sitemap:urlset/sitemap:url">
							<tr>
								<xsl:choose>
									<xsl:when test="position() mod 2 != 1">
										<xsl:attribute name="class">odd</xsl:attribute>
									</xsl:when>
								</xsl:choose>
								<td>
									<xsl:variable name="itemURL">
										<xsl:value-of select="sitemap:loc"/>
									</xsl:variable>
									<a href="{$itemURL}">
										<xsl:value-of select="sitemap:loc"/>
									</a>
								</td>
								<td>
									<xsl:value-of select="count(image:image)"/>
								</td>';
if ( empty( $type ) ) :
$xsl .= '						<td>
									<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
								</td>
								<td>
									<xsl:value-of select="concat(substring(sitemap:lastmod,0,11),concat(\' \', substring(sitemap:lastmod,12,5)))"/>
								</td>';
endif;
$xsl .= '					</tr>
						</xsl:for-each>
					</table>
				</div>
				<div id="footer">
					<p>' . wp_kses( sprintf( ent2ncr( __( '<em>Generated</em> by <a href="%s" target="_blank">Jetpack for WordPress</a>', 'jetpack' ) ), 'https://jetpack.com' ), array( 'a' => array( 'href' => true, 'title' => true ) ) ) . '</p>
				</div>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>';