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

Pre-build WordPress REST API responses and serve them as fast JSON snapshots from Smooth CDN.

== Description ==
Smooth API Accelerator helps you turn selected WordPress REST API endpoints into fast, CDN-delivered JSON snapshots.

Instead of generating the same REST API responses on every request, the plugin lets you select endpoints, build static JSON snapshots, and sync them to Smooth CDN. Your frontend, mobile app, headless site, or external client can then fetch predictable JSON files from CDN URLs with low latency and better cache behavior.

The plugin is designed for WordPress projects where API performance, stable JSON delivery, and controlled endpoint syncing matter.

Use it for headless WordPress sites, React or Next.js frontends, mobile apps, public API-like content feeds, and high-traffic REST API responses that do not need to be generated dynamically on every request.

== Why use Smooth API Accelerator? ==
* ⚡ **Faster WordPress REST API delivery** – serve selected API responses as CDN-delivered JSON files
* 🌍 **Edge-ready JSON** – make API data available through Smooth CDN for lower latency
* 🔄 **Automatic updates** – refresh synced endpoints after content and taxonomy changes
* 📦 **Static JSON snapshots** – predictable, cache-friendly output for frontends and apps
* 🔒 **Optional protected delivery** – restrict access to selected JSON files when needed
* 🧠 **Cleaner payloads** – optionally generate structured block data and remove raw content
* 🧩 **Headless-friendly workflow** – prepare WordPress data for React, Next.js, mobile apps, and static frontends

Perfect for:
* Headless WordPress websites
* Frontends built with React, Next.js, Astro, Vue, or other frameworks
* Mobile apps using WordPress as a backend
* Sites that expose public content through the WordPress REST API
* High-traffic REST API endpoints that benefit from static JSON delivery
* Projects that need a controlled JSON sync workflow instead of custom scripts

== How it works ==
1. Connect your WordPress site to Smooth CDN using account mode or guest mode
2. Discover available WordPress REST API endpoints
3. Select the endpoints you want to accelerate
4. The plugin generates JSON snapshots for selected endpoints
5. Synced JSON files are uploaded to Smooth CDN
6. Your frontend, app, or external client can use fast CDN URLs instead of generating the same REST API response on every request

== 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 with account mode or guest mode
* REST API endpoint discovery from wp-admin
* Clear separation between synced and available endpoints
* 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 JSON 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
* Developer hooks for custom route refresh rules and payload adjustments

== 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.2.3 =
* Updated plugin catalogue description.

= 1.2.2 =
* Improved blocks field handling for page endpoints.

= 1.2.1 =
* Fixed endpoint unsync and purge cleanup reliability.

= 1.2.0 =
* Added setup wizard for API Accelerator onboarding.

= 1.1.0 =
* Added project access management for synced JSON endpoints.

= 1.0.8 =
* Maintenance update.

= 1.0.7 =
* Removed project level tokens.

= 1.0.6 =
* Minor UI changes.

= 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.2.3 =
Maintenance update.

= 1.2.2 =
Improves blocks field handling for page endpoints.

= 1.2.1 =
Improves endpoint unsync and purge cleanup reliability.

= 1.2.0 =
Adds onboarding wizard.

= 1.1.0 =
Maintenance update.

== License ==
GPLv2 or later
