Lokaler JSON speichert Feldgruppendefinitionen als .json Dateien in Ihrem Theme, was Versionskontrolle und plattformübergreifende Bereitstellung ermöglicht. Erfordert PRO-Lizenz.
Dies ist das eigene lokale JSON-Format von Field Forge und verwendet standardmäßig fieldforge-json/. Das ACF-Migrationstool versteht auch die lokalen JSON-Quelldateien von ACF aus acf-json/group_*.json, sodass eine Website ACF-Feldgruppen importieren kann, selbst wenn die acf-field-group und acf-field Datenbankbeiträge fehlen.
Einrichtung
- Aktivieren Sie lokalen JSON in Field Forge > Einstellungen.
- Erstellen Sie das Verzeichnis:
your-theme/fieldforge-json/ - Feldgruppen werden automatisch in diesem Verzeichnis gespeichert, wenn sie bearbeitet werden.
bash
your-theme/
fieldforge-json/
group_1_product-fields.json
group_2_hero-section.json
.htaccess # Auto-created: "Deny from all"
index.php # Auto-created: silenceBidirektionale Synchronisierung
Field Forge erkennt JSON-Änderungen beim Laden der Admin-Oberfläche:
- JSON zu DB: Neue oder geänderte JSON-Dateien werden in die Datenbank importiert.
- DB zu JSON: Datenbankänderungen werden in JSON-Dateien exportiert.
Bereitstellungsworkflow
text
Development Staging Production
----------- ------- ----------
1. Edit field 3. git pull 5. git pull
groups in UI 4. Visit admin -> 6. Visit admin ->
2. git commit auto-sync auto-sync
fieldforge-json/ JSON -> DB JSON -> DBProgrammatische Synchronisierung
php
// Force export all groups to JSON
$local_json = FIELDFORGE_Local_JSON::instance();
$count = $local_json->save_all();
// Check for differences
$diff = $local_json->get_diff();
// Returns: ['new_in_json' => [...], 'new_in_db' => [...], 'modified' => [...], 'in_sync' => [1, 3]]
// Run sync (JSON wins)
$result = $local_json->sync( 'json_to_db' );
// Run sync (DB wins)
$result = $local_json->sync( 'db_to_json' );—