ACF Block Styles location
WordPress and ACF plugin to allow a Field Group Location for every block style registered.
by David Lapointe Gilbert · github.com/davidwebca/acf-block-style-location · website
★ 2stars
6composer installs
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/davidwebca/acf-block-style-location/archive/refs/heads/main.zipAlso on Packagist as davidwebca/acf-block-style-location:
composer require davidwebca/acf-block-style-locationFrom the readme
ACF Block Style Location
:bangbang: | WARNING! This plugin is probably unstable since it fiddles its way around to find React instances in the page.
:---: | :---
Now that you've been warned: Hey, welcome! For those of you who use block styles and ACF Blocks, you probably wonder why it's not possible to register a group field for a specific block style.
The simple reason is probably because it's unreliable right now in the current Gutenberg APIs (2021-12-20), but it might change soon. In the meantime, I've hacked around this solution that 1) caches the block styles as a transient; 2) finds the ACF form React instance in the dom; 3) forces the refresh of the ACF form when we click a block style.
This is far from perfect, but if it can be of any use to someone, good!
Requirements
- Composer
Installation
Install via Composer:
Or simply download zip of this repo and place in your plugins directory!
Setup
You'll need to first visit a Gutenberg-enabled page to prune the block styles cache. This is simply because WordPress doesn't allow fetching Block Styles on non-gutenberg pages (yet) since they can still be registered from the JavaScript API only. ACF adheres to that and only