This extension for Advanced Custom Fields that makes it possible to manage your field-groups through the console of wp-cli. The goal of this project is to make life easier for developers who working on Wordpress projects that use Advanced Custom Fields and love the WP-CLI command line tools.
- Advanced custom fields did not interface with WP-CLI
- Sharing
field-groupsthrough XML or PHP code caused problems with differences between development, test, staging and production enviroments when shared with XML. - No direct SVN or GIT support without manually putting the exported PHP or XML into a versioned directory.
- Naming convention for XML files was always the same, resulting in renaming hassle.
- Only using the generated
field-groupson runtime through PHP code infunctions.phpdisables the editing mode (which is an awesome UI that we require). So importing should be possible.
- Advanced Custom Fields plugin
wp-clihttp://wp-cli.org/
This project adds the acf command to wp-cli with the following subcommands:
-
wp acf: Default test and prints the help overview. -
wp acf status: provides a list of foundfield-groupsin the current database of your Wordpress project. -
wp acf export:- creates a
field-groupdirectory into your current theme's directory. - creates a directory with the
field-groupname for each fieldgroup. - creates a
data.phpanddata.xmlfor eachfield-groupinside their respective folders. - creates a uniqid file that contains the id used by ACF to identify the field
- use
wp acf export allto export everything without prompting
- creates a
-
wp acf import: imports the XML(s) fromactive-theme/field-groups/{field-group_name}/data.xml`- When using wp acf import a selection menu apears to choose which field-group to import
-
wp acf clean: cleans up the database from all found ACF post types and their coupledpost_metavalues, use this after you've edited thefield-groupsin the UI and used export to generate the newdata.phpfiles. Watch out: cannot be undone.
- install
wp-clihttp://wp-cli.org/ - clone this repo as
advanced-custom-fields-wpcliin your plugins directory - activate
advanced-custom-fields-wpcliplugin through "wp plugin activate advanced-custom-fields-wpcli" (or activate in the plugin menu) - open a terminal and go to your wordpress directory
- type
wp(and see theacfcommands if installed correctly) - type
wp acfto test theacf-wpcliextension - start using the commands as explained in "Commands"
When the plugin is enabled, any exported field groups found on the filesystem in your theme's field-groups folder will be added to Wordpress at runtime.
- make
acf-wpcliextension update-proof - clean up code and refractor
- add more comments and versioning
- try to fix the
wp-importerproblem that caused the use of copied code fromwp-importerplugin - release this plugin as official WordPress plugin