Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

cafe_export_field_groups()

Purpose

Exports field group definitions (groups, fields, settings, location rules) as a versioned CAFE export document. Stored values are never included. The same exporter powers CAFE → Tools → Export. Guide: Tools.

Syntax

cafe_export_field_groups( array $group_keys = [] ): array|WP_Error

Parameters

Parameter Type Default Description
$group_keys string[] [] Keys of the groups to export, e.g. [ 'group_contact' ]. Empty exports every group except the trash.

Return value

The export document (an array ready for wp_json_encode()), or a WP_Error with the code cafe_export_unknown_group when a key does not exist or the group is in the trash.

Example

// Save all field groups into your theme, e.g. to keep them in Git.
$document = cafe_export_field_groups();

if ( ! is_wp_error( $document ) ) {
	file_put_contents(
		get_stylesheet_directory() . '/cafe-field-groups.json',
		wp_json_encode( $document, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )
	);
}

Notes

  • The output is deterministic: an unchanged schema exports identical JSON.
  • Groups and fields are identified by their keys, never by database IDs.
  • Media settings (e.g. a Default Image) are exported empty: attachment IDs only mean something on the site they come from.
  • Sensitive field types (Password) never export a default value.
  • Format details: Tools → JSON format.