default.php
2.33 KB
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
<?php
/**
* XML template for our sitemap index pages.
*
* @since 4.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// phpcs:disable
?>
<urlset
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
<?php if ( ! $advanced || ! apply_filters( 'aioseo_sitemap_images', $excludeImages ) ): ?>
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1"
<?php endif; ?>
>
<?php foreach ( $entries as $entry ) {
if ( ! is_array( $entry ) || ! array_key_exists( 'loc', $entry ) || ! $entry['loc'] ) {
continue;
}
?>
<url>
<loc<?php echo ! empty( $entry['language'] ) ? ' language="' . $entry['language'] . '"' : ''; ?>><?php aioseo()->sitemap->output->escapeAndEcho( $entry['loc'] ); ?></loc><?php
if ( array_key_exists( 'languages', $entry ) && count( $entry['languages'] ) ) {
foreach ( $entry['languages'] as $language ) {
?>
<xhtml:link rel="alternate" hreflang="<?php echo esc_attr( $language['language'] ); ?>" href="<?php echo esc_url( $language['location'] ); ?>" /><?php
}
}
if ( array_key_exists( 'lastmod', $entry ) && $entry['lastmod'] ) {
?>
<lastmod><?php aioseo()->sitemap->output->escapeAndEcho( $entry['lastmod'] ); ?></lastmod><?php
}
if ( array_key_exists( 'changefreq', $entry ) && $entry['changefreq'] ) {
?>
<changefreq><?php aioseo()->sitemap->output->escapeAndEcho( $entry['changefreq'] ); ?></changefreq><?php
}
if ( array_key_exists( 'priority', $entry ) && $entry['priority'] ) {
?>
<priority><?php aioseo()->sitemap->output->escapeAndEcho( $entry['priority'] ); ?></priority><?php
}
if ( array_key_exists( 'images', $entry ) && $entry['images'] ) {
foreach ( $entry['images'] as $image ) {
$image = (array) $image;
?>
<image:image>
<image:loc><?php aioseo()->sitemap->output->escapeAndEcho( $image['image:loc'] ); ?></image:loc><?php
if ( array_key_exists( 'image:caption', $image ) && $image['image:caption'] ) {
?>
<image:caption><?php aioseo()->sitemap->output->escapeAndEcho( $image['image:caption'] ); ?></image:caption><?php
}
if ( array_key_exists( 'image:title', $image ) && $image['image:title'] ) {
?>
<image:title><?php aioseo()->sitemap->output->escapeAndEcho( $image['image:title'] ); ?></image:title><?php
}
?>
</image:image><?php
}
}
?>
</url>
<?php } ?>
</urlset>