diff --git a/config/config.ini.example b/config/config.ini.example
index fadb0ac..14c5980 100644
--- a/config/config.ini.example
+++ b/config/config.ini.example
@@ -99,6 +99,16 @@ default.thumbnail = ""
; Enable view Counter, the options is "true" and "false". If set to "true", you can see the Counts in Admin page.
views.counter = "true"
+; Sitemap priorities between "0.0" and "1.0". Set "false" to disable a sitemap for the given type. (See /sitemap.xml)
+sitemap.priority.base = "1.0"
+sitemap.priority.post = "0.5"
+sitemap.priority.static = "0.5"
+sitemap.priority.tag = "0.5"
+sitemap.priority.archiveDay = "0.5"
+sitemap.priority.archiveMonth = "0.5"
+sitemap.priority.archiveYear = "0.5"
+sitemap.priority.author = "0.5"
+
; Also install pre-release
prerelease = false
diff --git a/system/includes/functions.php b/system/includes/functions.php
index ac4095c..c20a0c3 100644
--- a/system/includes/functions.php
+++ b/system/includes/functions.php
@@ -1678,6 +1678,8 @@ function sitemap_page_path()
// Generate sitemap.xml.
function generate_sitemap($str)
{
+ $default_priority = '0.5';
+
header('X-Robots-Tag: noindex');
echo '';
@@ -1685,49 +1687,95 @@ function generate_sitemap($str)
if ($str == 'index') {
echo '';
- echo '' . site_url() . 'sitemap.base.xml';
- echo '' . site_url() . 'sitemap.post.xml';
- echo '' . site_url() . 'sitemap.static.xml';
- echo '' . site_url() . 'sitemap.tag.xml';
- echo '' . site_url() . 'sitemap.archive.xml';
- echo '' . site_url() . 'sitemap.author.xml';
+
+ if (config('sitemap.priority.base') !== 'false') {
+ echo '' . site_url() . 'sitemap.base.xml';
+ }
+
+ if (config('sitemap.priority.post') !== 'false') {
+ echo '' . site_url() . 'sitemap.post.xml';
+ }
+
+ if (config('sitemap.priority.static') !== 'false') {
+ echo '' . site_url() . 'sitemap.static.xml';
+ }
+
+ if (config('sitemap.priority.tag') !== 'false') {
+ echo '' . site_url() . 'sitemap.tag.xml';
+ }
+
+ if (config('sitemap.priority.archiveDay') !== 'false' || config('sitemap.priority.archiveMonth') !== 'false' || config('sitemap.priority.archiveYear') !== 'false') {
+ echo '' . site_url() . 'sitemap.archive.xml';
+ }
+
+ if (config('sitemap.priority.author') !== 'false') {
+ echo '' . site_url() . 'sitemap.author.xml';
+ }
+
echo '';
+
} elseif ($str == 'base') {
+ $priority = (config('sitemap.priority.base')) ? config('sitemap.priority.base') : '1.0';
+
echo '';
- echo '' . site_url() . '1.0';
+
+ if ($priority !== 'false') {
+ echo '' . site_url() . '' . $priority . '';
+ }
+
echo '';
+
} elseif ($str == 'post') {
- $posts = sitemap_post_path();
+ $priority = (config('sitemap.priority.post')) ? config('sitemap.priority.post') : $default_priority;
+
+ $posts = [];
+ if ($priority !== 'false') {
+ $posts = sitemap_post_path();
+ }
echo '';
foreach ($posts as $p) {
- echo '' . $p->url . '0.5';
+
+ echo '' . $p->url . '' . $priority . '' . date('Y-m-d', $p->date) . '';
}
echo '';
+
} elseif ($str == 'static') {
- $posts = sitemap_page_path();
+ $priority = (config('sitemap.priority.static')) ? config('sitemap.priority.static') : $default_priority;
+
+ $posts = [];
+ if ($priority !== 'false') {
+ $posts = sitemap_page_path();
+ }
echo '';
- if (!empty($posts)) {
+ foreach ($posts as $p) {
- foreach ($posts as $p) {
- echo '' . $p->url . '0.5';
- }
+ echo '' . $p->url . '' . $priority . '';
}
echo '';
+
} elseif ($str == 'tag') {
- $posts = get_post_unsorted();
+ $priority = (config('sitemap.priority.tag')) ? config('sitemap.priority.tag') : $default_priority;
+
+ $posts = [];
+ if ($priority !== 'false') {
+ $posts = get_post_unsorted();
+ }
+
$tags = array();
- if (!empty($posts)) {
+ echo '';
+
+ if($posts) {
foreach ($posts as $index => $v) {
$arr = explode('_', $v);
@@ -1743,21 +1791,24 @@ function generate_sitemap($str)
$tag[] = site_url() . 'tag/' . strtolower($t);
}
- echo '';
-
if (isset($tag)) {
$tag = array_unique($tag, SORT_REGULAR);
foreach ($tag as $t) {
- echo '' . $t . '0.5';
+ echo '' . $t . '' . $priority . '';
}
}
-
- echo '';
}
+
+ echo '';
+
} elseif ($str == 'archive') {
+ $priorityDay = (config('sitemap.priority.archiveDay')) ? config('sitemap.priority.archiveDay') : $default_priority;
+ $priorityMonth = (config('sitemap.priority.archiveMonth')) ? config('sitemap.priority.archiveMonth') : $default_priority;
+ $priorityYear = (config('sitemap.priority.archiveYear')) ? config('sitemap.priority.archiveYear') : $default_priority;
+
$posts = sitemap_post_path();
$day = array();
$month = array();
@@ -1775,34 +1826,48 @@ function generate_sitemap($str)
echo '';
- foreach ($day as $d) {
- echo '' . $d . '0.5';
+ if ($priorityDay !== 'false') {
+ foreach ($day as $d) {
+ echo '' . $d . '' . $priorityDay . '';
+ }
}
- foreach ($month as $m) {
- echo '' . $m . '0.5';
+ if ($priorityMonth !== 'false') {
+ foreach ($month as $m) {
+ echo '' . $m . '' . $priorityMonth . '';
+ }
}
- foreach ($year as $y) {
- echo '' . $y . '0.5';
+ if ($priorityYear !== 'false') {
+ foreach ($year as $y) {
+ echo '' . $y . '' . $priorityYear . '';
+ }
}
echo '';
+
} elseif ($str == 'author') {
- $posts = sitemap_post_path();
- $author = array();
+ $priority = (config('sitemap.priority.author')) ? config('sitemap.priority.author') : $default_priority;
- foreach ($posts as $p) {
- $author[] = $p->authorUrl;
- }
+ $author = [];
+ if ($priority !== 'false') {
- $author = array_unique($author, SORT_REGULAR);
+ $posts = sitemap_post_path();
+
+ foreach ($posts as $p) {
+ $author[] = $p->authorUrl;
+ }
+
+ $author = array_unique($author, SORT_REGULAR);
+ }
echo '';
- foreach ($author as $a) {
- echo '' . $a . '0.5';
+ if ($priority !== 'false') {
+ foreach ($author as $a) {
+ echo '' . $a . '' . $priority . '';
+ }
}
echo '';