From ea6430c010b2b4dae56f146443bf05a7e4939995 Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Sun, 4 Jun 2023 09:05:45 +0100
Subject: [PATCH] New plugin to add Sitemap link to robots.txt

---
 robots-txt.php | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 robots-txt.php

diff --git a/robots-txt.php b/robots-txt.php
new file mode 100644
index 0000000..78e53ac
--- /dev/null
+++ b/robots-txt.php
@@ -0,0 +1,18 @@
+<?php
+/*
+ * Plugin Name: A/I - Robots.txt
+ * Description: Customize robots.txt with per-site sitemap links
+ * Version: 0.0.1
+ * Author: Autistici/Inventati
+ * Author URI: https://autistici.org
+ */
+
+function ai_robots_txt_add_sitemap($output, $public) {
+    if ($public != '0') {
+        $sitemap_url = get_site_url(null, "/wp-sitemap.xml");
+        $output .= "\nSitemap: {$sitemap_url}\n";
+    }
+    return $output;
+}
+
+add_filter('robots_txt', 'ai_robots_txt_add_sitemap', 99, 2);
-- 
GitLab