=== Paradarum CDN Purge ===
Contributors: paradarum
Tags: cdn, cache, purge, paradarum
Requires at least: 5.6
Tested up to: 6.5
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically purges the Paradarum CDN cache for the routes affected whenever you publish or modify content.

== Description ==

When you publish, update, unpublish or trash a post or page — or edit a term, or a comment is approved — this plugin invalidates the affected CDN routes through the Paradarum API, using your account API key.

It does not just purge the single post: it also purges the home page, the relevant category/tag/taxonomy archives, author and date archives, feeds and sitemaps, so visitors never see a stale listing.

= How it decides what to purge =

* **Hybrid (recommended):** the post and the home are purged by exact path; archives and listings are purged by path prefix (`starts_with`) so their pagination (`/page/2/`, …) is invalidated too.
* **Surgical:** only exact URLs are purged (archive pagination may stay cached).
* **Broad:** any change flushes the whole site cache.

All routes affected during a request are collected, de-duplicated and sent to the API in a single batch call on `shutdown`, so saving in the editor is never slowed down by many HTTP requests.

== Configuration ==

1. Go to **Settings → Paradarum CDN**.
2. Enter the **API URL** (e.g. `https://api.paradarum.com`) and your **API key** (`pdm_…`).
3. Click **Check & detect**. The plugin lists your account properties and auto-selects the one whose hostname matches this site. If it can't detect one, pick it from the list.
4. Click **Save property**. Automatic purging is now active.

The API key is stored encrypted (AES-256-CBC, keyed from your site's `AUTH_KEY`/`AUTH_SALT`). You may also define it in `wp-config.php`:

    define( 'PARADARUM_API_KEY', 'pdm_…' );
    define( 'PARADARUM_API_URL', 'https://api.paradarum.com' );

A constant takes precedence over the value stored in the database.

== WP-CLI ==

    wp paradarum status
    wp paradarum purge --all
    wp paradarum purge --url=/blog/
    wp paradarum purge --post=42

== Developer hooks ==

Trigger a purge from your own code:

    do_action( 'paradarum_purge', array( home_url( '/landing/' ) ) );
    do_action( 'paradarum_purge', 'all' );

Filter the final purge items before they are sent:

    add_filter( 'paradarum_cdn_purge_items', function ( $items, $trigger ) {
        return $items;
    }, 10, 2 );

== Changelog ==

= 1.0.0 =
* Initial release.
