pixel-icon-web/php/sitemap.php

34 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2024-11-15 18:18:33 +08:00
<?php
$root = "https://sqkhor.com/pixel-icons/";
$icon_json = json_decode(file_get_contents(__DIR__ . "/assets/icons.json"), true);
ob_start();
?>
<?='<' . '?xml version="1.0" encoding="UTF-8"?' . '><' . '?xml-stylesheet type="text/xsl" href="//sqkhor.com/wp-content/plugins/wordpress-seo/css/main-sitemap.xsl"?' . '>' ?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-image/1.1 http://www.google.com/schemas/sitemap-image/1.1/sitemap-image.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://sqkhor.com/pixel-icons/</loc>
<lastmod><?= date("Y-m-d", filemtime(__DIR__ . "/assets/icons.json")) ?></lastmod>
<changefreq>always</changefreq>
<image:image>
<image:loc>https://sqkhor.com/pixel-icons/cover3.1.png</image:loc>
</image:image>
</url>
<?php foreach ($icon_json as $filename => $tags): ?>
<?php $icon_name = str_replace(".svg", "", $filename) ?>
<url>
<loc><?= $root . $icon_name ?></loc>
<lastmod><?= date("Y-m-d", filectime(__DIR__ . "/icons/$filename")) ?></lastmod>
<changefreq>yearly</changefreq>
<image:image>
<image:loc><?= $root . "preview/$icon_name.png" ?></image:loc>
</image:image>
</url>
<?php endforeach ?>
</urlset>
<?php
$sitemap = ob_get_clean();
file_put_contents(__DIR__ . "/pixel-icons-sitemap.xml", $sitemap);
header("Content-type: application/xml");
echo $sitemap;