Home Forums Feature Requests Static Definitions of Fields


Static Definitions of Fields

  • Hi,

    I absolutely love using the ACF plugin and addons, but one thing that I seem to get a bit irky with is when it comes to synchronise changes between different install locations of a WordPress site.

    Say, for example, I have a local and remote copy of a website for a client. My work is done locally, and then uploaded to the remote copy for the client to see at regular intervals. If, for whatever reason, a new field needs to be added, then I need to do one of the following:

    • Create on Local. Export on local then import on remote.
    • Create on Local. Create on remote.

    The former being better for larger additions or alterations, the latter being better for smaller additions or alterations.

    I would like to see a better, easier solution, a way to easily synch changes between two installs. A solution would be to be able to statically declare field groups and fields, done most likely in one of two ways:

    • Activation/Synch Hook: Declare fields in code, press a button in plugin settings to fire a hook which syncs the code up with the existing fields in the database. Would probably need some config options like whether to replace/overwrite fields which already exist or replace the entire setup each time.
    • Always Active: Essentially just check on each relevant load for any static decelerations of fields and load them in when needed.

    Obviously both have pros and cons. The former would require a lot more initial setup, but allows the field decelerations to be stored in the DB in the exact same way they are now, only requiring you to add a method to import them. The latter requires you to add an extra check each time the field definitions are required to see if any exist in the code and would raise issues like compatibility between code / server field definitions (overwriting names, etc), but would provide instant sync when code is uploaded.

    Either way, you would need to define a setup of some sort to be able to easily create/define fields and field groups.

    Thanks for reading!

  • ACF does have a method to load fields from code using “Export as PHP”. However, this does require that the fields are first created using the GUI, then exported, deleted via GUI, and included via PHP file… got me thinking about an “ACF field generator” which would basically be a web-based version of the GUI that outputs PHP code (like but for ACF). Of course, then there’s always the issue of name conflicts, incompatibility with custom field types, etc…

  • A static field is in programming languages is the declaration for a variable that will be held in common by all instances of a class. The static modifier determines the class variable as one that will be applied universally to all instances of a particular class. A static field may also be called a class variable.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Static Definitions of Fields’ is closed to new replies.