Completed
Push — kraftbj-patch-2 ( 82c983...ae9d16 )
by
unknown
513:58 queued 503:20
created

Jetpack_Sitemap_Stylist   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 755
Duplicated Lines 62.25 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 470
loc 755
rs 9.7391
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A sanitize_with_links() 0 14 1
B sitemap_xsl() 103 103 1
B sitemap_index_xsl() 102 102 1
B image_sitemap_xsl() 131 131 1
B video_sitemap_xsl() 134 134 1
B news_sitemap_xsl() 0 111 1
B sitemap_xsl_css() 0 76 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
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 Jetpack
8
 * @since 4.7.0
9
 */
10
11
/**
12
 * Builds the XSL files required by Jetpack_Sitemap_Manager.
13
 *
14
 * @since 4.7.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.7.0
36
	 * @link http://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.7.0
63
	 *
64
	 * @return string The contents of the xsl file.
65
	 */
66 View Code Duplication
	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
			__(
73
				'This is an XML 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>.',
74
				'jetpack'
75
			),
76
			array(
77
				1 => 'http://jetpack.com/',
78
				2 => 'https://www.google.com/',
79
				3 => 'https://www.bing.com/',
80
			)
81
		);
82
83
		$more_info = self::sanitize_with_links(
84
			__(
85
				'You can find more information on XML sitemaps at <a href="%1$s" target="_blank">sitemaps.org</a>',
86
				'jetpack'
87
			),
88
			array(
89
				1 => 'http://sitemaps.org',
90
			)
91
		);
92
93
		$generated_by = self::sanitize_with_links(
94
			__(
95
				'Generated by <a href="%s" target="_blank">Jetpack for WordPress</a>',
96
				'jetpack'
97
			),
98
			array(
99
				1 => 'https://jetpack.com',
100
			)
101
		);
102
103
		$css = self::sitemap_xsl_css();
104
105
		return <<<XSL
106
<?xml version='1.0' encoding='UTF-8'?>
107
<xsl:stylesheet version='2.0'
108
  xmlns:html='http://www.w3.org/TR/REC-html40'
109
  xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
110
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
111
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
112
<xsl:template match="/">
113
<html xmlns="http://www.w3.org/1999/xhtml">
114
<head>
115
  <title>$title</title>
116
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
117
  <style type='text/css'>
118
$css
119
  </style>
120
</head>
121
<body>
122
  <div id='description'>
123
    <h1>$title</h1>
124
    <p>$description</p>
125
    <p>$more_info</p>
126
  </div>
127
  <div id='content'>
128
    <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
129
    <table>
130
      <tr>
131
        <th>#</th>
132
        <th>$header_url</th>
133
        <th>$header_lastmod</th>
134
      </tr>
135
      <xsl:for-each select="sitemap:urlset/sitemap:url">
136
        <tr>
137
          <xsl:choose>
138
            <xsl:when test='position() mod 2 != 1'>
139
              <xsl:attribute name="class">odd</xsl:attribute>
140
            </xsl:when>
141
          </xsl:choose>
142
          <td>
143
            <xsl:value-of select = "position()" />
144
          </td>
145
          <td>
146
            <xsl:variable name='itemURL'>
147
              <xsl:value-of select='sitemap:loc'/>
148
            </xsl:variable>
149
            <a href='{\$itemURL}'>
150
              <xsl:value-of select='sitemap:loc'/>
151
            </a>
152
          </td>
153
          <td>
154
            <xsl:value-of select='sitemap:lastmod'/>
155
          </td>
156
        </tr>
157
      </xsl:for-each>
158
    </table>
159
  </div>
160
  <div id='footer'>
161
    <p>$generated_by</p>
162
  </div>
163
</body>
164
</html>
165
</xsl:template>
166
</xsl:stylesheet>\n
167
XSL;
168
	}
169
170
	/**
171
	 * Returns the xsl of a sitemap index xml file as a string.
172
	 *
173
	 * @access public
174
	 * @since 4.7.0
175
	 *
176
	 * @return string The contents of the xsl file.
177
	 */
178 View Code Duplication
	public static function sitemap_index_xsl() {
179
		$title          = esc_html( ent2ncr( __( 'XML Sitemap Index', 'jetpack' ) ) );
180
		$header_url     = esc_html( ent2ncr( __( 'Sitemap URL', 'jetpack' ) ) );
181
		$header_lastmod = esc_html( ent2ncr( __( 'Last Modified', 'jetpack' ) ) );
182
183
		$description = self::sanitize_with_links(
184
			__(
185
				'This is an XML Sitemap Index 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>.',
186
				'jetpack'
187
			),
188
			array(
189
				1 => 'http://jetpack.com/',
190
				2 => 'https://www.google.com/',
191
				3 => 'https://www.bing.com/',
192
			)
193
		);
194
195
		$more_info = self::sanitize_with_links(
196
			__(
197
				'You can find more information on XML sitemaps at <a href="%1$s" target="_blank">sitemaps.org</a>',
198
				'jetpack'
199
			),
200
			array(
201
				1 => 'http://sitemaps.org',
202
			)
203
		);
204
205
		$generated_by = self::sanitize_with_links(
206
			__(
207
				'Generated by <a href="%s" target="_blank">Jetpack for WordPress</a>',
208
				'jetpack'
209
			),
210
			array(
211
				1 => 'https://jetpack.com',
212
			)
213
		);
214
215
		$css = self::sitemap_xsl_css();
216
217
		return <<<XSL
218
<?xml version='1.0' encoding='UTF-8'?>
219
<xsl:stylesheet version='2.0'
220
  xmlns:html='http://www.w3.org/TR/REC-html40'
221
  xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
222
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
223
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
224
<xsl:template match="/">
225
<html xmlns="http://www.w3.org/1999/xhtml">
226
<head>
227
  <title>$title</title>
228
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
229
  <style type='text/css'>
230
$css
231
  </style>
232
</head>
233
<body>
234
  <div id='description'>
235
    <h1>$title</h1>
236
    <p>$description</p>
237
    <p>$more_info</p>
238
  </div>
239
  <div id='content'>
240
    <table>
241
      <tr>
242
        <th>#</th>
243
        <th>$header_url</th>
244
        <th>$header_lastmod</th>
245
      </tr>
246
      <xsl:for-each select='sitemap:sitemapindex/sitemap:sitemap'>
247
        <tr>
248
          <xsl:choose>
249
            <xsl:when test='position() mod 2 != 1'>
250
              <xsl:attribute name="class">odd</xsl:attribute>
251
            </xsl:when>
252
          </xsl:choose>
253
          <td>
254
            <xsl:value-of select = "position()" />
255
          </td>
256
          <td>
257
            <xsl:variable name='itemURL'>
258
              <xsl:value-of select='sitemap:loc'/>
259
            </xsl:variable>
260
            <a href='{\$itemURL}'>
261
	            <xsl:value-of select='sitemap:loc'/>
262
  	        </a>
263
          </td>
264
          <td>
265
            <xsl:value-of select='sitemap:lastmod'/>
266
          </td>
267
        </tr>
268
      </xsl:for-each>
269
    </table>
270
  </div>
271
  <div id='footer'>
272
    <p>$generated_by</p>
273
  </div>
274
</body>
275
</html>
276
</xsl:template>
277
</xsl:stylesheet>\n
278
XSL;
279
	}
280
281
	/**
282
	 * Returns the xsl of an image sitemap xml file as a string.
283
	 *
284
	 * @access public
285
	 * @since 4.7.0
286
	 *
287
	 * @return string The contents of the xsl file.
288
	 */
289 View Code Duplication
	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.
423
	 *
424
	 * @access public
425
	 * @since 4.7.0
426
	 *
427
	 * @return string The contents of the xsl file.
428
	 */
429 View Code Duplication
	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.
566
	 *
567
	 * @access public
568
	 * @since 4.7.0
569
	 *
570
	 * @return string The contents of the xsl file.
571
	 */
572
	public static function news_sitemap_xsl() {
573
		$title          = esc_html( ent2ncr( __( 'XML News Sitemap', 'jetpack' ) ) );
574
		$header_url     = esc_html( ent2ncr( __( 'Page URL', 'jetpack' ) ) );
575
		$header_title   = esc_html( ent2ncr( __( 'Title', 'jetpack' ) ) );
576
		$header_pubdate = esc_html( ent2ncr( __( 'Publication Date', 'jetpack' ) ) );
577
578
		$description = self::sanitize_with_links(
579
			__(
580
				'This is an XML News 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>.',
581
				'jetpack'
582
			),
583
			array(
584
				1 => 'http://jetpack.com/',
585
				2 => 'https://www.google.com/',
586
				3 => 'https://www.bing.com/',
587
			)
588
		);
589
590
		$more_info = self::sanitize_with_links(
591
			__(
592
				'You can find more information on XML sitemaps at <a href="%1$s" target="_blank">sitemaps.org</a>',
593
				'jetpack'
594
			),
595
			array(
596
				1 => 'http://sitemaps.org',
597
			)
598
		);
599
600
		$generated_by = self::sanitize_with_links(
601
			__(
602
				'Generated by <a href="%s" target="_blank">Jetpack for WordPress</a>',
603
				'jetpack'
604
			),
605
			array(
606
				1 => 'https://jetpack.com',
607
			)
608
		);
609
610
		$css = self::sitemap_xsl_css();
611
612
		return <<<XSL
613
<?xml version='1.0' encoding='UTF-8'?>
614
<xsl:stylesheet version='2.0'
615
  xmlns:html='http://www.w3.org/TR/REC-html40'
616
  xmlns:sitemap='http://www.sitemaps.org/schemas/sitemap/0.9'
617
  xmlns:news='http://www.google.com/schemas/sitemap-news/0.9'
618
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
619
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>
620
<xsl:template match="/">
621
<html xmlns="http://www.w3.org/1999/xhtml">
622
<head>
623
  <title>$title</title>
624
  <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
625
  <style type='text/css'>
626
$css
627
  </style>
628
</head>
629
<body>
630
  <div id='description'>
631
    <h1>$title</h1>
632
    <p>$description</p>
633
    <p>$more_info</p>
634
  </div>
635
  <div id='content'>
636
    <!-- <xsl:value-of select="count(sitemap:urlset/sitemap:url)"/> -->
637
    <table>
638
      <tr>
639
        <th>#</th>
640
        <th>$header_url</th>
641
        <th>$header_title</th>
642
        <th>$header_pubdate</th>
643
      </tr>
644
      <xsl:for-each select="sitemap:urlset/sitemap:url">
645
        <tr>
646
          <xsl:choose>
647
            <xsl:when test='position() mod 2 != 1'>
648
              <xsl:attribute name="class">odd</xsl:attribute>
649
            </xsl:when>
650
          </xsl:choose>
651
          <td>
652
            <xsl:value-of select = "position()" />
653
          </td>
654
          <xsl:variable name='pageURL'>
655
            <xsl:value-of select='sitemap:loc'/>
656
          </xsl:variable>
657
          <td>
658
            <a href='{\$pageURL}'>
659
              <xsl:value-of select='sitemap:loc'/>
660
            </a>
661
          </td>
662
          <td>
663
            <a href='{\$pageURL}'>
664
              <xsl:value-of select='news:news/news:title'/>
665
            </a>
666
          </td>
667
          <td>
668
            <xsl:value-of select='news:news/news:publication_date'/>
669
          </td>
670
        </tr>
671
      </xsl:for-each>
672
    </table>
673
  </div>
674
  <div id='footer'>
675
    <p>$generated_by</p>
676
  </div>
677
</body>
678
</html>
679
</xsl:template>
680
</xsl:stylesheet>\n
681
XSL;
682
	}
683
684
	/**
685
	 * The CSS to be included in sitemap xsl stylesheets;
686
	 * factored out for uniformity.
687
	 *
688
	 * @access public
689
	 * @since 4.7.0
690
	 *
691
	 * @return string The CSS.
692
	 */
693
	public static function sitemap_xsl_css() {
694
		return <<<CSS
695
    body {
696
      font: 14px 'Open Sans', Helvetica, Arial, sans-serif;
697
      margin: 0;
698
    }
699
700
    a {
701
      color: #3498db;
702
      text-decoration: none;
703
    }
704
705
    h1 {
706
      margin: 0;
707
    }
708
709
    #description {
710
      background-color: #81a844;
711
      color: #FFF;
712
      padding: 30px 30px 20px;
713
    }
714
715
    #description a {
716
      color: #fff;
717
    }
718
719
    #content {
720
      padding: 10px 30px 30px;
721
      background: #fff;
722
    }
723
724
    a:hover {
725
      border-bottom: 1px solid;
726
    }
727
728
    th, td {
729
      font-size: 12px;
730
    }
731
732
    th {
733
      text-align: left;
734
      border-bottom: 1px solid #ccc;
735
    }
736
737
    th, td {
738
      padding: 10px 15px;
739
    }
740
741
    .odd {
742
      background-color: #E7F1D4;
743
    }
744
745
    #footer {
746
      margin: 20px 30px;
747
      font-size: 12px;
748
      color: #999;
749
    }
750
751
    #footer a {
752
      color: inherit;
753
    }
754
755
    #description a, #footer a {
756
      border-bottom: 1px solid;
757
    }
758
759
    #description a:hover, #footer a:hover {
760
      border-bottom: none;
761
    }
762
763
    img.thumbnail {
764
      max-height: 100px;
765
      max-width: 100px;
766
    }
767
CSS;
768
	}
769
770
}
771