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

Preview missing for duplicated flexible layouts #11

Closed
romanklabal opened this issue Aug 9, 2022 · 1 comment
Closed

Preview missing for duplicated flexible layouts #11

romanklabal opened this issue Aug 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@romanklabal
Copy link
Contributor

When you create a flexible layout, duplicate it (using the built-in ACF quick action) and then keep the fields intact in the copy by just renaming them, they keep their internal key. Thats means they are being mistakenly skipped as duplicates by this retrieve_flexible_keys_from_fields() check in /classes/main.php:

if ( ! empty( $keys[ $layout_field['key'] ] ) ) {

and ignored, which means the preview for any but the most recent layouts is missing.

I have fixed it by combining the parent layout key (which does change upon duplication) with the field key so the key is really unique, like this:

if ( ! empty( $field['key'] . '-' . $layout_field['key'] ] ) ) {
	continue;
}
$keys[ $field['key'] . '-' . $layout_field['key'] ] = $layout_field['name'];

Happy to provide you with an example or with a PR if you'd like.

@jameelmoses
Copy link
Owner

@romanklabal thanks for reporting. i'd gladly review a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants