=== Meerkat Markdown for AI Visibility ===
Contributors: andybrin
Author URI: https://curnaglias.com
Tags: sitemap, generator, llm, markdown
Requires at least: 6.8
Tested up to: 7.0
Stable tag: 4.2
Requires PHP: 8.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Generate a Markdown list of your URLs to help AI-driven tools understand your website.

== Description ==
Meerkat Markdown for AI Visibility collects URLs using WordPress queries and generates an llms.txt file (short for “Large Language Models”) in the website’s root directory — optionally providing dynamic .md files — to help AI-based systems better understand and make use of the site’s content. The llms.txt is stored in the root directory. You can configure the number of URLs, set a minimum word count, and exclude specific categories or tags. File generation can be triggered manually or scheduled to run automatically.

**Features**

* Gathers URLs with WordPress queries; the `wp-sitemap.xml` URL is only added to `llms.txt` as metadata.
* Creates `llms.txt` with `[Title • host/path](URL): content` entries.
* Add a custom site description to the file header.
* Limit export to 100 entries or process all URLs.
* Posts or pages with fewer than 15 words are skipped: they do not count toward
  the 100-entry limit and are omitted from `llms.txt`.
* Choose 30, 50, 100 words or the full text per entry.
* Exclude categories and tags.
* Sort `llms.txt` entries by popularity or most recent first.
* Optionally serve dynamic `.md` files for published posts, pages and public custom post types. Responses include canonical, noindex and MIME-sniffing protection headers.
* Generates a valid XML sitemap for Markdown URLs without declaring `llms.txt` as a sitemap or blocking it in `robots.txt`.
* Manual generation via the **Generate Files Now** button.
* Timezone-aware WP-Cron schedule (hourly, daily, weekly, monthly or disabled) with configurable local run time and daylight-saving-safe rescheduling.
* Save settings with the **Save Changes** button.

== Installation ==
1. Upload the `meerkat-markdown-for-ai-visibility` folder to `/wp-content/plugins/`.
2. Activate the plugin through the **Plugins** menu.
3. Visit **Settings → Markdown for AI** and click **Generate Files Now** to create the first file.

== Frequently Asked Questions ==

= Where is `llms.txt` stored? =
It is written to the site root directory (same level as the top-level `index.php`).

= How can I regenerate it? =
Use the **Generate Files Now** button or wait for the scheduled cron run.

= How do I change the schedule? =
Select a new frequency and click **Save Changes** on the settings page.

= What happens when I uninstall the plugin? =
All plugin options and generated sitemap files are removed automatically. The plugin deletes `llms.txt` only when the file can be identified as plugin-generated. Existing files created manually or by another plugin are preserved.

= How do I enable the dynamic sitemap? =
Add the following snippet to your theme's `functions.php` or a small helper plugin:

`add_filter( 'mrmrkdofa_enable_dynamic_sitemap', '__return_true' );`

Afterwards visit **Settings → Permalinks** and save changes once so WordPress refreshes the rewrite rules.

== Screenshots ==
1. Settings page with Generate and Save Changes buttons plus cron frequency selection.

== Changelog ==

= 4.2 =

* Protects existing `llms.txt` files: files not owned by this plugin are neither overwritten nor removed during uninstall.
* Manages only a clearly marked plugin block in `robots.txt` and preserves all unrelated directives.
* Supports dynamic Markdown URLs with plain WordPress permalinks through query-based endpoints.
* Propagates failed write, delete, permission and directory operations instead of reporting false success.
* Removes dynamic Markdown rewrite rules reliably when the feature or plugin is disabled.
* Corrects the settings description for canonical and X-Robots-Tag headers.
* Updates repository metadata and moves older release notes to changelog.txt.
* Regenerates the translation template from the current source.
* Renames plugin classes and methods to WordPress-compatible naming conventions and normalizes formatting.
* Prevents shortcodes from being executed twice during llms.txt generation.
* Validates sitemap XML before accepting a fallback endpoint.
* Stages and rolls back generated files so failed sitemap generation does not partially update llms.txt.

= 4.1 =

* Adds a defensive DOMNode guard clause to the HTML-to-Markdown parser.
* Prevents PHP warnings when an unexpected or null node is passed to the recursive node processor.

= 4.0 =

**Major improvements**

**Security**

* Limits dynamic Markdown output to published, publicly accessible and non-password-protected content.
* Drafts, private posts and password-protected content are no longer exposed through `.md` URLs.
* Unknown Markdown URLs return a real HTTP 404 response instead of homepage content.
* Uses safe remote requests, validates AJAX permissions and adds canonical, noindex and MIME-sniffing protection headers.

**Generation, sitemaps and scheduling**

* Supports public custom post types and Elementor, Divi and Avada content.
* Generates a valid Markdown XML sitemap and removes obsolete robots.txt directives.
* Processes large sites in batches and validates root, upload and filter values.
* Uses timezone-aware calendar scheduling for hourly, daily, weekly and monthly runs.
* Cleans generated data, options, cron events and legacy robots.txt entries on uninstall.

Earlier release notes are included in `changelog.txt`.

== License ==
This plugin is open source software licensed under the GPLv2 (or later). See LICENSE.txt for license information.
