Sync watcher for ACF (a custom plugin)
Chisel theme co-locates ACF field group JSON with their ACF blocks and uses a custom xfive’s plugin to prevent DB/JSON drift.
Overview
- This feature is provided by the custom plugin
wp-content/plugins/xfive-sync-watcher-for-acf/. - Requires ACF 6.1+ (the watcher extends ACF’s internal admin class).
Sync Watcher
- Files:
- wp-content/plugins/xfive-sync-watcher-for-acf/xfive-sync-watcher-for-acf.php
- classes/Plugin.php
- Behavior (classes/Plugin.php):
- Extends
ACF_Admin_Internal_Post_Type_List(ACF 6.1+) and uses itssetup_sync()to detect unsynced groups. - Displays:
- Global admin notice on ACF Field Groups list when any unsynced: link to Sync view.
- Modal dialog on a single field group edit screen if that group is unsynced, with:
- View changes
- Sync data (nonce-protected)
- Ignore
- Enqueues admin CSS/JS for the modal only when relevant:
dist/css/plugin.cssdist/js/plugin.js
- Extends
- Safety check:
- If ACF isn’t active or < 6.1, shows a dismissible error notice and exits early.
Recommended workflow (dev)
- Create/modify fields:
- In ACF UI create a form group
- Save.
- Keep JSON in version control:
- Commit changes to each block’s
acf-jsonso teammates/CI get the same schema.
- Commit changes to each block’s
- Avoid overwrites:
- If the watcher modal appears while editing a group, review or sync before making changes to avoid overwriting a newer local JSON with database state.
- Sync flow:
- ACF Field Groups → Sync view shows all unsynced.
- Use plugin links: “View changes” or “Sync data”.
- After syncing, commit the updated JSON.
Summary
- A custom watcher plugin warns about unsynced groups, provides a modal on single-group edits, and links to Sync actions – reducing accidental overwrites.
- Commit JSON changes alongside block code for reliable team workflows.