=== Smooth API Accelerator ===
Contributors: smoothcdn
Tags: rest api, cache, json, cdn, performance
Requires at least: 6.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.5
License: GPLv2 or later

Accelerate your WordPress API performance with edge-ready delivery, powered by Smooth CDN.

== Description ==
Turn your WordPress REST API into a fast, edge-delivered data layer.

Smooth API Accelerator prepares your API responses for instant delivery through Smooth CDN. Instead of generating responses on every request, your data is pre-built, optimized, and served as static JSON files from the edge.

Connect your site once, select the endpoints you want, and let the plugin handle the rest.

== Why use Smooth API Accelerator? ==
* ⚡ **Faster API responses** – serve JSON from CDN instead of generating it on every request
* 🌍 **Edge delivery** – global availability with low latency
* 🔄 **Automatic updates** – keep your API data in sync after content changes
* 📦 **Static JSON snapshots** – predictable, cache-friendly responses
* 🔒 **Optional protected delivery** – restrict access to selected API data
* 🧠 **Cleaner payloads** – optional block parsing and content optimization

Perfect for:
* Headless WordPress setups
* Mobile apps using WordPress as a backend
* Frontends built with React, Next.js, or other frameworks
* High-traffic APIs that need stable and fast responses

== How it works ==
1. Connect your site to Smooth CDN (account or guest mode)
2. Discover available REST API endpoints
3. Select endpoints to accelerate
4. The plugin generates JSON snapshots and uploads them to Smooth CDN
5. Your API data is now served from fast CDN URLs

== External services ==
This plugin connects to Smooth CDN to create and manage the remote project used for JSON acceleration.

It communicates with Smooth CDN when you:

* start or complete the account or guest connection flow,
* fetch account or project metadata needed by the plugin,
* upload synced JSON snapshots,
* delete synced JSON snapshots with `Unsync` or `Purge endpoints`.

Depending on the action, the plugin may send:

* your site URL and site name,
* the generated project name derived from the site domain,
* authentication data needed to complete the Smooth CDN login flow,
* project identifiers and account metadata required to manage the connection,
* REST API JSON snapshots selected for sync, including paginated collection files,
* asset paths, filenames, and protection flags used to manage synced files.

Smooth CDN service links:

* Terms of Service: https://smoothcdn.com/terms
* Privacy Policy: https://smoothcdn.com/privacy

== Features ==
* Simple setup with unified connection and configuration view
* Smooth CDN connection in minutes (account or guest mode)
* Manual endpoint discovery with clear separation of synced and available routes
* One-click sync for selected endpoints
* Automatic re-sync after post and taxonomy updates
* Paginated collection sync with metadata manifest
* Optional `blocks` field generation for structured content
* Optional removal of raw `content` field for lighter responses
* Optional protected JSON delivery
* Lock mode for direct REST GET access via `wp-json`
* `Unsync` and `Purge endpoints` remove both local and CDN data
* Clear dashboard with sync and acceleration status

== Synced JSON layout ==
Single endpoints are uploaded as one JSON file:

	https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/pages/42.json

Collection endpoints are uploaded as:

	https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/posts.json
	https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/posts/page-1.json
	https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/posts/page-2.json

The collection metadata file contains:

	{
		"per_page": 50,
		"total_pages": 2,
		"pages": [
			"https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/posts/page-1.json",
			"https://cdn.smoothcdn.com/<user-slug>/<project-slug>/wp/v2/posts/page-2.json"
		]
	}

== Settings overview ==
Key settings that affect synced output:

* `Add blocks field` adds a normalized `blocks` field when supported content is available.
* `Remove content field` is available only when `Add blocks field` is enabled and removes `content` after `blocks` is added.
* `Protected assets` uploads synced JSON files as protected Smooth CDN assets.
* `Collection sync page size` controls pagination for collection endpoints. Available values: `10`, `25`, `50`, `100`. Default: `50`.
* `Auto scan and sync` controls how often WP-Cron runs automatic scan and sync.

Changing output-affecting settings invalidates previous sync markers and queues a faster full scan + sync through WP-Cron.

== Developer hooks ==
Use `scdn_api_accelerator_save_post_related_routes` to add custom routes/templates that should be refreshed and synced after `save_post`.

Example:

	add_filter( 'scdn_api_accelerator_save_post_related_routes', function( $rules, $post_id, $post ) {
		$rules[] = 'product|route:/custom/v1/products/{post_id}';
		$rules[] = 'product|template:/custom/v1/products';
		$rules[] = [
			'post_type' => 'page',
			'route'     => '/custom/v1/page-index',
		];

		return $rules;
	}, 10, 3 );

Use `scdn_api_accelerator_pre_send_json` to adjust endpoint payload before upload.

Example:

	add_filter( 'scdn_api_accelerator_pre_send_json', function( $data, $route, $context ) {
		if ( '/wp/v2/posts' === $route && is_array( $data ) ) {
			foreach ( $data as $index => $item ) {
				if ( ! is_array( $item ) ) {
					continue;
				}

				unset( $data[ $index ]['class_list'], $data[ $index ]['meta'] );
			}
		}

		return $data;
	}, 10, 3 );

== Maintenance ==
`Unsync` removes selected endpoints from sync, deletes their CDN files, and returns them to detected state.

`Purge endpoints` removes all synced data from Smooth CDN and clears local state.

== Changelog ==

= 1.0.5 =
* Switched protected JSON handling from global setting to per-endpoint control.

= 1.0.4 =
* Forced endpoint sync after changing `Protected assets`.
* Hid `Open` action for protected synced JSON assets.

= 1.0.3 =
* Overview dashboard adjustments.

= 1.0.2 =
* Added WordPress.org plugin icon and visual assets.

= 1.0.1 =
* Added WordPress.org plugin icon and visual assets.
* Improved plugin readme description and formatting.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.5 =
Maintenance update.

= 1.0.4 =
Maintenance update.

= 1.0.3 =
Maintenance update.

= 1.0.2 =
Maintenance update.

= 1.0.1 =
Adds WordPress.org plugin icon and improves the plugin readme.

= 1.0.0 =
Initial release.

== License ==
GPLv2 or later
