PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.16.7
Translate and Go multilingual – Automatic AI translation – wpLingua v2.16.7
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
wplingua / assets / sitemap.xsl

sitemap.xsl in Translate and Go multilingual – Automatic AI translation – wpLingua 2.16.7, at assets/sitemap.xsl

291 lines 12.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3 version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
6 xmlns:xhtml="http://www.w3.org/1999/xhtml"
7 xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
8 exclude-result-prefixes="sitemap xhtml image">
9
10 <xsl:output method="html" encoding="UTF-8" indent="yes"/>
11
12 <!-- Variables to count URLs (with or without namespace) -->
13 <xsl:variable name="urls-with-ns" select="sitemap:urlset/sitemap:url"/>
14 <xsl:variable name="urls-without-ns" select="urlset/url"/>
15 <xsl:variable name="total-urls" select="count($urls-with-ns) + count($urls-without-ns)"/>
16
17 <!-- Variables to count sitemap index entries (with or without namespace) -->
18 <xsl:variable name="sitemaps-with-ns" select="sitemap:sitemapindex/sitemap:sitemap"/>
19 <xsl:variable name="sitemaps-without-ns" select="sitemapindex/sitemap"/>
20 <xsl:variable name="total-sitemaps" select="count($sitemaps-with-ns) + count($sitemaps-without-ns)"/>
21
22 <!-- Determine sitemap type -->
23 <xsl:variable name="is-index" select="$total-sitemaps &gt; 0"/>
24
25 <xsl:template match="/">
26 <html lang="en">
27 <head>
28 <title>
29 <xsl:choose>
30 <xsl:when test="$is-index">XML Sitemap Index</xsl:when>
31 <xsl:otherwise>XML Sitemap</xsl:otherwise>
32 </xsl:choose>
33 </title>
34 <style>
35 body {
36 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
37 color: #333;
38 max-width: 1200px;
39 margin: 0 auto;
40 padding: 20px;
41 background: #f5f5f5;
42 }
43 h1 {
44 color: #0073aa;
45 border-bottom: 3px solid #0073aa;
46 padding-bottom: 10px;
47 }
48 .sitemap-info {
49 background: white;
50 padding: 15px;
51 border-radius: 5px;
52 margin-bottom: 20px;
53 box-shadow: 0 1px 3px rgba(0,0,0,0.1);
54 }
55 table {
56 width: 100%;
57 border-collapse: collapse;
58 background: white;
59 box-shadow: 0 1px 3px rgba(0,0,0,0.1);
60 border-radius: 5px;
61 overflow: hidden;
62 }
63 th {
64 background: #0073aa;
65 color: white;
66 padding: 12px 15px;
67 text-align: left;
68 font-weight: 600;
69 }
70 td {
71 padding: 12px 15px;
72 border-bottom: 1px solid #eee;
73 vertical-align: top;
74 }
75 tr:nth-child(odd) td {
76 background: #ffffff;
77 }
78 tr:nth-child(even) td {
79 background: #f9f9f9;
80 }
81 tr:hover td {
82 background: #eef6fc;
83 }
84 a {
85 color: #0073aa;
86 text-decoration: none;
87 word-break: break-all;
88 }
89 a:hover {
90 text-decoration: underline;
91 }
92 .translations {
93 margin-top: 10px;
94 padding-top: 10px;
95 border-top: 1px dashed #ddd;
96 }
97 .translation-row {
98 display: block;
99 margin: 5px 0;
100 font-size: 13px;
101 }
102 .lang-badge {
103 display: inline-block;
104 min-width: 20px;
105 padding: 2px;
106 margin-right: 10px;
107 background: #0073aa;
108 color: white;
109 border-radius: 3px;
110 font-size: 11px;
111 text-align: center;
112 font-weight: bold;
113 text-transform: uppercase;
114 }
115 .image-count {
116 display: inline-block;
117 padding: 3px 8px;
118 background: #46b450;
119 color: white;
120 border-radius: 3px;
121 font-size: 11px;
122 font-weight: bold;
123 }
124 .credit {
125 margin-top: 30px;
126 padding: 15px;
127 background: white;
128 border-radius: 5px;
129 text-align: center;
130 font-size: 13px;
131 color: #666;
132 box-shadow: 0 1px 3px rgba(0,0,0,0.1);
133 }
134 .credit a {
135 font-weight: 600;
136 }
137 .url-count {
138 color: #666;
139 font-size: 14px;
140 }
141 </style>
142 </head>
143 <body>
144 <xsl:choose>
145 <!-- Sitemap Index -->
146 <xsl:when test="$is-index">
147 <h1>XML Sitemap Index</h1>
148
149 <div class="sitemap-info">
150 <p class="url-count">
151 This sitemap index contains <strong><xsl:value-of select="$total-sitemaps"/></strong> sitemaps.
152 </p>
153 </div>
154
155 <table>
156 <thead>
157 <tr>
158 <th>Sitemap</th>
159 <th style="width: 180px;">Last Modified</th>
160 </tr>
161 </thead>
162 <tbody>
163 <!-- Sitemaps with namespace -->
164 <xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
165 <xsl:call-template name="sitemap-row">
166 <xsl:with-param name="loc" select="sitemap:loc"/>
167 <xsl:with-param name="lastmod" select="sitemap:lastmod"/>
168 </xsl:call-template>
169 </xsl:for-each>
170
171 <!-- Sitemaps without namespace (fallback) -->
172 <xsl:for-each select="sitemapindex/sitemap">
173 <xsl:call-template name="sitemap-row">
174 <xsl:with-param name="loc" select="loc"/>
175 <xsl:with-param name="lastmod" select="lastmod"/>
176 </xsl:call-template>
177 </xsl:for-each>
178 </tbody>
179 </table>
180 </xsl:when>
181
182 <!-- URL Sitemap -->
183 <xsl:otherwise>
184 <h1>XML Sitemap</h1>
185
186 <div class="sitemap-info">
187 <p class="url-count">
188 This sitemap contains <strong><xsl:value-of select="$total-urls"/></strong> URLs.
189 </p>
190 </div>
191
192 <table>
193 <thead>
194 <tr>
195 <th>URL</th>
196 <th style="width: 100px;">Images</th>
197 <th style="width: 180px;">Last Modified</th>
198 </tr>
199 </thead>
200 <tbody>
201 <!-- URLs with namespace -->
202 <xsl:for-each select="sitemap:urlset/sitemap:url">
203 <xsl:call-template name="url-row">
204 <xsl:with-param name="loc" select="sitemap:loc"/>
205 <xsl:with-param name="lastmod" select="sitemap:lastmod"/>
206 <xsl:with-param name="links" select="xhtml:link[@rel='alternate']"/>
207 <xsl:with-param name="images" select="image:image"/>
208 </xsl:call-template>
209 </xsl:for-each>
210
211 <!-- URLs without namespace (fallback) -->
212 <xsl:for-each select="urlset/url">
213 <xsl:call-template name="url-row">
214 <xsl:with-param name="loc" select="loc"/>
215 <xsl:with-param name="lastmod" select="lastmod"/>
216 <xsl:with-param name="links" select="xhtml:link[@rel='alternate']"/>
217 <xsl:with-param name="images" select="image:image"/>
218 </xsl:call-template>
219 </xsl:for-each>
220 </tbody>
221 </table>
222 </xsl:otherwise>
223 </xsl:choose>
224
225 <div class="credit">
226 Multilingual XML Sitemap powered by
227 <a href="https://wplingua.com" target="_blank" rel="noopener noreferrer">wpLingua</a>
228 </div>
229 </body>
230 </html>
231 </xsl:template>
232
233 <!-- Template to display a sitemap index row -->
234 <xsl:template name="sitemap-row">
235 <xsl:param name="loc"/>
236 <xsl:param name="lastmod"/>
237
238 <tr>
239 <td>
240 <a href="{$loc}">
241 <xsl:value-of select="$loc"/>
242 </a>
243 </td>
244 <td>
245 <xsl:value-of select="$lastmod"/>
246 </td>
247 </tr>
248 </xsl:template>
249
250 <!-- Template to display a URL row -->
251 <xsl:template name="url-row">
252 <xsl:param name="loc"/>
253 <xsl:param name="lastmod"/>
254 <xsl:param name="links"/>
255 <xsl:param name="images"/>
256
257 <tr>
258 <td>
259 <a href="{$loc}">
260 <xsl:value-of select="$loc"/>
261 </a>
262 <xsl:if test="$links">
263 <div class="translations">
264 <xsl:for-each select="$links">
265 <span class="translation-row">
266 <span class="lang-badge">
267 <xsl:value-of select="@hreflang"/>
268 </span>
269 <a href="{@href}">
270 <xsl:value-of select="@href"/>
271 </a>
272 </span>
273 </xsl:for-each>
274 </div>
275 </xsl:if>
276 </td>
277 <td>
278 <xsl:variable name="image-count" select="count($images)"/>
279 <xsl:if test="$image-count &gt; 0">
280 <span class="image-count">
281 <xsl:value-of select="$image-count"/>
282 </span>
283 </xsl:if>
284 </td>
285 <td>
286 <xsl:value-of select="$lastmod"/>
287 </td>
288 </tr>
289 </xsl:template>
290
291 </xsl:stylesheet>