AdvancedCustomFields / acf

Advanced Custom Fields
http://advancedcustomfields.com/
823 stars 168 forks source link

5.9 beta - Convert WYSIWYG content to innerBlocks #323

Open JiveDig opened 4 years ago

JiveDig commented 4 years ago

I have an ACF block heavily used on a few large sites. I'd like to update the block to only use innerBlocks in place of an existing WYSIWG field. Trying to figure out a way to get_field( 'my_content' ) and pass that to the innerBlocks (or some version of that) the next time the post/page is edited.

elliotcondon commented 4 years ago

Hi @JiveDig

Great question. I'm not exactly sure how this would be possible, but I'll start searching for a solution đź‘Ť

JiveDig commented 4 years ago

I started testing passing the existing value to the template, only if there is an existing value. Didn’t get it to work, but that would still require the “old” field to be registered so it works with get_field(). Another layer or difficulty is that the old field won’t be available anymore since it’s now just using innerBlocks.

JiveDig commented 3 years ago

Still not able to to do this. Tried a few ways and got stuck. I'm thinking the only solution may be to leave the old field registered but hide it via conditional logic that is always false, then load_field filter to check for that value or something like that. It'd get tricky though as we'd need to clear the old field value on save of the new field.

elliotcondon commented 3 years ago

Yep, this is a tricky one indeed. I've still got this on my to-do for RC2, but haven't looked into it just yet.

JiveDig commented 3 years ago

Just to update: I released an update to my plugin which now uses InnerBlocks.

Here's the logic:

I'd love a way that didn't require copy/paste or leaving the old field registered, but this solution is working as of now.

Markup 2020-09-02 at 13 57 00
elliotcondon commented 3 years ago

Hi @JiveDig. Great work!

I agree. An automated solution for setting the InnerBlocks content would be ideal. I still have this on my to-do list for the 5.9 version and hope to find a solution in the future.

For now, I'm glad you have a working update đź‘Ť.

P.S. Can you remind me of the plugin you are working on? I've lost track, sorry.

JiveDig commented 3 years ago

Thanks Elliot. Still super excited for inner blocks. I have a few things I need to convert/update, but this one took priority. It's a GitHub-only plugin as of now https://github.com/maithemewp/mai-notices