%d field groups will be converted from PHP to JSON configuration.
', count($groups)); echo 'Convert Field Groups'; } } /** * Convert the field groups and output the conversion page */ function admin_page_convert() { $groups = get_groups_to_convert(); echo sprintf('Converting %d field groups from PHP to JSON configuration...
', count($groups)); echo 'Done. Now remove the PHP field group configuration.
'; } /** * Get the PHP field groups which will be converted. * * @return array */ function get_groups_to_convert() { $groups = acf_get_local_field_groups(); if (!$groups) return []; return array_filter($groups, function($group) { return $group['local'] == 'php'; }); } /** * Convert a field group to JSON * * @param array $group * @return bool */ function convert_group($group) { $group['fields'] = acf_get_local_fields($group['key']); return acf_write_json_field_group($group); }