WP Manifestindependent plugin directory
manifest / developer / acf-sync

Advanced Custom Fields: Sync

Sync ACF configs more easily

by Code for the People Ltd · github.com/cftp/acf-sync · website

10stars
1forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/cftp/acf-sync/archive/refs/heads/master.zip

Readme

ACF Sync

  1. Ensure the WordPress Importer and ACF plugins are installed and active
  2. Install this plugin as a mu-plugin
  3. Add a hook in a sub-plugin, mu-plugin, theme or wherever to use the acf_sync_xml_file_location filter to specify the location for your XML config file, it is expected that you will commit this file to remain in sync with your collaborators
  4. Use the export/import buttons (everyone loves buttons) in "WordPress Admin Area" > "Custom Fields" > "Sync" to keep in sync
  5. Profit

Before including any ACF Fields you've exported to PHP, do a check like:

    if ( ! class_exists( 'ACF_Dev_Mode' ) or ! ACF_Dev_Mode::active() ) {
        // Require the PHP exports from ACF here
    }

Whenever you need to change an ACF field:

  1. Enable dev mode by adding define( 'ACF_DEV_MODE', true ); to your local-config.php.
  2. Make sure your local copy of the theme is up to date. Import fields using ACF sync.
  3. Then makes your amends, do a PHP export to acf_fields.php in the Keystone Structure plugin and commit.
  4. Then do an ACF sync and commit and push the changes to the .xml file in the theme.
  5. Disable dev mode.

Note that this plugin needs to be present on development and production, otherwise if you have fields defined in both DB (through the WP admin area) and in the PHP exports, you will see double sets of fields.

Read the full README on GitHub →