Skip to content

Commit

Permalink
Fixes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
romanklabal committed Aug 9, 2022
1 parent 1fefe9b commit 5ce2f49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions classes/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ protected function retrieve_flexible_keys_from_fields( $fields, &$keys ) {
foreach ( $fields as $field ) {
if ( 'flexible_content' === $field['type'] ) {
foreach ( $field['layouts'] as $layout_field ) {
// Prevent skipping layout fields with identical keys from
// different fields by creating a unique identifier.
$field_identifier = $field['key'] . '-' . $layout_field['key'];

// Don't revisit keys we've recorded already
if ( ! empty( $keys[ $layout_field['key'] ] ) ) {
if ( ! empty( $keys[ $field_identifier ] ) ) {
continue;
}

$keys[ $layout_field['key'] ] = $layout_field['name'];
$keys[ $field_identifier ] = $layout_field['name'];

// Flexible content has a potentially recursive structure. Each layout
// has its own sub-fields that could in turn be flexible content.
Expand Down

0 comments on commit 5ce2f49

Please sign in to comment.