YAML-ised fields configuration for ACF
This package extends Advanced Custom Fields plugin for WordPress and enable developers to write their ACF fields blazingly fast in configuration file.
composer require jofrysutanto/windsor
functions.php
file:
require_once __DIR__ . '/vendor/autoload.php';
functions.php
file:
function register_acf_windsor()
{
\Windsor\Capsule\Manager::make()->register();
}
add_action('acf/init', 'register_acf_windsor');
[your-active-theme]/acf-fields/index.yaml
, where [your-active-theme]
refers to your currently active WordPress theme directory. At minimum, your entry file should contain:
fields: []
pages: []
blocks: []
your-theme/acf-fields/page-default.acf.yaml
:
title: 'Page Default'
key: 'page_default'
position: 'acf_after_title'
hide_on_screen: []
location:
-
-
param: 'page_template'
operator: '=='
value: 'default'
fields:
heading:
type: text
label: Heading
fields: []
pages:
- page-default.acf.yaml
blocks: []
If you have existing field groups created through ACF interface, you can easily export them out to YAML by enabling the exporter through ui
configuration when registering Windsor:
function register_acf_windsor()
{
\Windsor\Capsule\Manager::make([
'ui' => true
])
->register();
}
add_action('acf/init', 'register_acf_windsor');
Once enabled, you access the exporter within WordPress backend by clicking on Custom Fields > Export to YAML link in sidebar.
More information about this tool can be found in configurations section.
Check out full documentations at https://windsor-docs.netlify.app/
Only VSCode integration is available at the moment. To enable autocompletion and useful snippets, follow the installation steps below:
settings.json
):
"yaml.schemas": {
"https://windsor-docs.netlify.app/schema.json": "*.acf.yaml"
}
This package is written to be used with Advanced Custom Fields plugin by Elliot Condon, who deserves most of the credits for delivering and maintaining such an incredible plugin for WordPress developers.
If you have not already started using Advanced Custom Fields, be sure to check it out; it will definitely be worth your while.