https://github.com/yardinternet/wp-acf-registrar
An Acorn package to register ACF fields
https://github.com/yardinternet/wp-acf-registrar
Last synced: about 4 hours ago
JSON representation
An Acorn package to register ACF fields
- Host: GitHub
- URL: https://github.com/yardinternet/wp-acf-registrar
- Owner: yardinternet
- License: mit
- Created: 2024-12-10T13:39:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-06-01T19:46:14.000Z (27 days ago)
- Last Synced: 2026-06-16T17:18:12.182Z (12 days ago)
- Language: PHP
- Size: 296 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# ACF Registrar
[](https://github.com/yardinternet/wp-acf-registrar/actions/workflows/format-php.yml)
[](https://github.com/yardinternet/wp-acf-registrar/actions/workflows/phpstan.yml)
[](https://github.com/yardinternet/wp-acf-registrar/actions/workflows/run-tests.yml)
## Features
- [x] Register ACF Field groups
- [x] Register ACF Forms
- [x] Register ACF Option Pages
## Installation
This package can be installed using composer
```shell
composer require yard/acf-registrar
```
# Usage
To use this package in a standard WordPress plugin, you can use the `Registrar` to register hooks.
main file:
```php
/**
* Plugin Name: My Plugin
*/
require __DIR__ . '/vendor/autoload.php';
$fieldGroups$ = [
\Plugin\FieldGroupClass::class,
\Plugin\AnotherFieldGroupClass::class,
];
$registrar = new \Yard\Acf\Registrar();
$registrar->addFieldGroups($fieldGroups);
$registrar->addForm(\Plugin\FormClass::class);
$registrar->addOptionPage(\Plugin\OptionPageClass::class);
$registrar->register();
```
## FieldGroup Usage
Extend `Yard\Acf\Registar\FieldGroup` to define a field group.
Add the class to `config/acf-registrar` in the `field_groups` key.
See [Extended ACF](https://github.com/vinkla/extended-acf) for documentation about registering fields.
```php
instructions('De naam van de persoon.')
->required(true)
->placeholder('Voer de naam in'),
];
}
public function getLocation(): array
{
return [
Location::where('post_type', '==', 'person'),
];
}
}
```
## Forms Usage
Extend `Yard\Acf\Registrar\Forms` to define a front-end form.
Add the class to `config/acf-registrar` under the `forms` key.
`getId()` is required to define the form id, additional methods can be used to overwrite the given defaults.
```php