Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with WPML may require moving away from acf-builder. Is there a way to get JSON/PHP to import into ACF Pro UI? #184

Open
cjezowicz opened this issue Mar 13, 2024 · 3 comments

Comments

@cjezowicz
Copy link

We've used StoutLogic / acf-builder on almost all of our projects for the past few years. However this is the first time we've been asked to add translation functionality to an existing site. We chose WPML because it seemed to support everything we needed out of the box. During implementation we ran into an issue where translations would not find the ACF field groups and instead display Notice: Undefined variable: content_blocks in /var/www/html/web/app/uploads/cache/bf12783b09440d36e34dfe9a69b1e37c0cd6fa9b.php on line 2

We're working with WPML to see if there is a resolution to this issue: https://wpml.org/forums/topic/translating-acf-fields-3 and we've since found a post with a similar if not same issue that we're running into: https://wpml.org/forums/topic/repeaters-flexible-content-generated-with-acf_add_local_field-and-wpml/

This brings me to my actual question/issue. Is there any migration tools, processes, or procedures that can take the StoutLogic / acf-builder ACF fields and convert them to JSON OR import then back into ACF PRO as database values?

@stevep
Copy link
Member

stevep commented Mar 14, 2024

I don't have much experience with WPML but ACF Builder isn't doing anything much different than if you were to register your acf fields manually. It is just building the field group config array you plug in directly to acf_add_local_field_group

https://www.advancedcustomfields.com/resources/register-fields-via-php/#add-within-an-action

And with that said, any way that currently exists to transform field groups registered with PHP to JSON should be apply here as well. I haven't tried it but could look at: https://github.com/underlost/acf-php-to-json/

Looking at the code of that plugin, this line should return all the field groups you define with ACF Builder and register with acf_add_local_field_group:

 $groups = acf_get_local_field_groups();

Being mindful of when the field group registration happens in the code, and when that function is called

@coreyhicks

This comment was marked as resolved.

@stevep
Copy link
Member

stevep commented Mar 25, 2024

@coreyhicks That is interesting. Great find! Your comment is marked as resolved, but did that indeed fix the issue for you with WPML?

I'm wondering what implications this change would have, and if it might be a breaking change for any external packages depending on ACF Builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants