项目作者: jofrysutanto

项目描述 :
YAML-ised fields configuration for ACF
高级语言: PHP
项目地址: git://github.com/jofrysutanto/windsor.git
创建时间: 2020-01-07T23:16:24Z
项目社区:https://github.com/jofrysutanto/windsor

开源协议:Apache License 2.0

下载


ACF Windsor

Latest Stable Version Total Downloads Latest Unstable Version License

This package extends Advanced Custom Fields plugin for WordPress and enable developers to write their ACF fields blazingly fast in configuration file.

ACF Windsor

Features

  • Permanently lock your custom fields in your version-controlled code, preventing accidental edits that quickly leads to out-of-sync configurations.
  • Create your fields much faster, especially when complimented with the IDE integration.
  • Composition is at the heart of it. Write your own rules to further supercharge your development productivity.

Getting Started

  • The easiest way to install Windsor is to use composer:
    1. composer require jofrysutanto/windsor
  • If you are using VSCode, be sure to add the Schema file to your configuration.
  • Ensure you have included composer auto-loader file. If you’re not sure, add the following line into your functions.php file:
    1. require_once __DIR__ . '/vendor/autoload.php';
  • Register Windsor on ACF initialization. You may also do this in functions.php file:
    1. function register_acf_windsor()
    2. {
    3. \Windsor\Capsule\Manager::make()->register();
    4. }
    5. add_action('acf/init', 'register_acf_windsor');
  • Create YAML entry file at [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:
    1. fields: []
    2. pages: []
    3. blocks: []
  • Test your installation:
    • Create your first custom field YAML, for example create a file your-theme/acf-fields/page-default.acf.yaml:
      1. title: 'Page Default'
      2. key: 'page_default'
      3. position: 'acf_after_title'
      4. hide_on_screen: []
      5. location:
      6. -
      7. -
      8. param: 'page_template'
      9. operator: '=='
      10. value: 'default'
      11. fields:
      12. heading:
      13. type: text
      14. label: Heading
    • Register this new ACF file in your index:
      1. fields: []
      2. pages:
      3. - page-default.acf.yaml
      4. blocks: []
    • You have successfully registered a new field group which will be made available when creating a new default page.
  • Check out our full documentation below. Now go and create beautiful ACF fields!

Migrating Existing Fields

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:

  1. function register_acf_windsor()
  2. {
  3. \Windsor\Capsule\Manager::make([
  4. 'ui' => true
  5. ])
  6. ->register();
  7. }
  8. 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.

Learn More

Check out full documentations at https://windsor-docs.netlify.app/

IDE Integration

Only VSCode integration is available at the moment. To enable autocompletion and useful snippets, follow the installation steps below:

  • If not already installed, download and enable YAML language server extension.
  • Update your VSCode settings (i.e. settings.json):
    1. "yaml.schemas": {
    2. "https://windsor-docs.netlify.app/schema.json": "*.acf.yaml"
    3. }

Credits

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.