<?php
require_once __DIR__ . '/includes/seo.php';

header('Content-Type: application/xml; charset=UTF-8');

$pages = seo_sitemap_pages();
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach ($pages as $page) :
    $file = __DIR__ . '/' . $page['file'];
    $lastmod = is_readable($file) ? date('Y-m-d', filemtime($file)) : date('Y-m-d');
?>
  <url>
    <loc><?php echo seo_escape(seo_url($page['path'])); ?></loc>
    <lastmod><?php echo seo_escape($lastmod); ?></lastmod>
  </url>
<?php endforeach; ?>
</urlset>
