e44a33cd8e9d8b927298e67d02a347b53e6c7fe0
WP Site Sync
WP Site Sync is a WordPress plugin that allows users to synchronize content between different WordPress sites. It is particularly useful for developers and site administrators who manage multiple WordPress installations and need to keep content consistent across them.
Current status
- Plugin scaffold with settings storage, admin UI, REST API, and WP-Cron schedule wiring.
- REST authentication uses shared key + HMAC headers (
X-Site-Sync-Key,X-Site-Sync-Signature,X-Site-Sync-Timestamp) with replay protection. - Sync engine implements outbound/inbound flow for posts/pages/CPTs and taxonomies: posts delta by
post_modified_gmt/ID with last-modified-wins, term delta by term ID, external IDs stored in post/term meta, and term slugs synced on posts. Media entities are emitted with metadata checkpoints and fetched via authenticated REST download (fallback to GUID); uploads/ downloads carry SHA-256 checksums for optional integrity validation. - Sync state storage added (checkpoints/mappings placeholder) with admin status for last run and errors; manual "Sync Now" and handshake test; configurable meta whitelist on the settings screen.
Setup (developer preview)
- Activate the plugin.
- In the admin menu, open Site Sync and configure:
- Site ID (auto-generated) and shared secret (can be rotated).
- Peer site ID + peer site URL.
- Enable sync and choose a WP-Cron interval (default every 5 minutes).
- Use the
/wp-json/site-sync/v1/handshakeendpoint to verify connectivity. - Trigger a manual sync via the Sync Now button.
- Use Run Handshake in the admin page to test connectivity/auth (shows notice).
Notes on sync behavior (current)
- Outbox batches terms (by term ID) then posts/pages/CPTs (by
post_modified_gmtthen ID), then media attachments (bypost_modified_gmt/ID); checkpoints prevent repeats; tombstones emitted for trashed posts/media and queued with a capped buffer. - Inbox applies posts with conflict resolution (newer modified wins), syncs taxonomy slugs, applies whitelisted post meta (via settings field or
site_sync/post_meta_keys, defaults to_thumbnail_id); applies terms with parent lookup; media fetched from peer via authenticated REST media endpoint (fallback to GUID) and sideloaded; delete payloads trash/delete posts and media and delete terms. - External IDs are stored per post (
_site_sync_external_id) and per term (_site_sync_term_external_id); media uses_site_sync_media_external_id. - Media upload endpoint accepts authenticated uploads (10MB cap, MIME allowlist, optional checksum header); downloads include checksum header and are verified when present; delete hooks now emit tombstones for posts/media/terms.
- Logging persisted (last 200 entries) and displayed in admin status; tombstone enqueue deduplicates and caps; delete hooks skip when applying remote deletes to avoid loops.
Notes
- Sync runs outbound-only from the initiating site, satisfying private-site constraints.
- Manual sync trigger and full processing pipeline are planned for subsequent iterations.
Description
Languages
PHP
100%