Closed kasprzyk-sz closed 5 months ago
I've added a PR for task 1: https://github.com/visual-framework/vf-wp/pull/1276
Basically the ACF block ID was used as a unique name for the <iframe>
and its JavaScript callback function (to auto-resize the iframe responsively). The new ID format included hypens causing a JS error.
A quick fix is to use an md5 hash of the ID. The actual value doesn't matter it just needs to be unique.
Thanks @dbushell!
I still noticed a few weird things going on:
See the issues on this video:
https://github.com/visual-framework/vf-wp/assets/54020899/86bb615d-a7b5-45ff-8bd9-b27cd35965fa
ah ok I will investigate!
Seems like the block ID issue was only a minor one and there are more compatibility issues with ACF 6.
I think I've found a solution to fix the styles and it has also fixed the admin toobar.
The duplicate block issue is still confusing me I'll report back when I figure that out.
I've found another bug with the ACF block ID change https://www.advancedcustomfields.com/resources/whats-new-with-acf-blocks-in-acf-6/#block-id
Due to the dynamic block ID generation, this change is backwards compatible for the majority of users, unless you use parse_blocks() to read ACF data, and rely on it returning a block ID.
This is something we are doing to allow is_container
setting. Blocks like the vf-divider
can go full-width and break out the centre column.
It still works in the Gutenberg editor, but in the front-end template there is no block ID so it cannot read this setting and fails to go full-width.
The ACF blog post suggest a few workarounds. I think it can be fixed. That might also fix the duplicate block bug.
Notes on task 2 (block.json) - research in progress
Currently we're using acf_register_block_type that allows render_callback
to be a dynamic PHP function. The new ACF block.json only allows renderCallback
to be a string (function name). That would have to be a global function which isn't great. Or we maybe use renderTemplate
and have the callback logic in there.
Al the block plugins that extend VFWP_Block
have a static name method:
static public function get_name() {
return 'vfwp-button';
}
This gets used to generate the config for acf_register_block_type
and to find the template path etc. If that config is moving to a JSON file, we need to get the name from there, rather than hard-coding it.
This PR https://github.com/visual-framework/vf-wp/pull/1276 fixes the block renders
Please let me know if you find more issues @kasprzyk-sz
Duplicate block issue should be fixed https://github.com/visual-framework/vf-wp/issues/1275#issuecomment-1717508768 Also the container toggle issue should be fixed https://github.com/visual-framework/vf-wp/issues/1275#issuecomment-1717980853
It no longer relies on any ACF block IDs because they're not unique anymore and not available in some templates.
If you edit block fields in the right-side column the iframe render has to refresh so it might disappear for a second. It shouldn't be any slower than it was before. It's difficult to test on my local machine because Docker is super slow (it's not using native mac arm images).
I'm back next Tuesday to fix more bugs!
good news! think I've fixed the slow issue. I'll have it updated soon.
That's great! Thank you David. We'll wait with the deployment until you push the latest changes then
hi @kasprzyk-sz I've added another PR https://github.com/visual-framework/vf-wp/pull/1278
I don't think you'll need to test a production/staging deployment as it should be fast enough locally now.
Works great @dbushell!
Are we good to merge https://github.com/visual-framework/vf-wp/pull/1278? I'll see if I can get the block.json example done this afternoon.
I'm working on the block.json support in this branch: https://github.com/visual-framework/vf-wp/tree/feature/acf-block-json
A basic version works for the Button block. I need to tidy it up and make sure JSX / inner blocks work (and other settings).
Added a PR https://github.com/visual-framework/vf-wp/pull/1283 for block.json support.
Current ACF version: 5.9.1
Tasks:
1. Fix ACF blocks rendering in the WP Gutenberg editor
The ACF v6.0.0 introduces major updates to blocks and as a result, the blocks registered with ACF are not rendered in the editor. After some investigation, I suspect that the problem is related to the changes in the block ID.
In the current version, a block id has the following format:
block_64f9c4e7edb03
. After the update the id is generated differently and outputsacf_block_123-12-1212
. This format is causing an error in this function:https://github.com/visual-framework/vf-wp/blob/master/wp-content/plugins/vf-gutenberg/vf-gutenberg.php#L337
Nevertheless, I'm not sure if this is the main problem or if there are more dependencies which affect the rendering.
2. Upgrade legacy blocks to block.json
ACF guide to update legacy blocks
ACF v6.2.1.1 download
advanced-custom-fields-pro.zip
To update the plugin - copy and replace all files in
.../vf-wp/dist/vfwp-external-plugins/advanced-custom-fields-pro