Has anybody made a php class that helps generate acf fields in php?
The thought comes to mind every time I open my custom fields file. For one of my projects its 3300 lines long! It becomes a bear to manage sometimes.
A php generator class would make it a little more compact to generate fields. something like this for example:
$generator = new AcfGenerator('field-group-id' ,'Field Group Name');
$generator->addTextField("Field Label", "optional-field-name", array("formatting" => "html"));
Which would be the same as writing out something similar to this
register_field_group(array (
'id' => 'acf_field-group-id',
'title' => 'Field Group Name',
'fields' => array (
array (
'key' => 'field_530e74135f6',
'label' => 'Field Label',
'name' => 'optional-field-name',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
),
'options' => array (
'position' => 'normal',
'layout' => 'default ',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
It could be refined even more, just a quick example of what I’m thinking of.
Just wondering if anybody has started working on something like this and to see what other developers think.