-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into stories/fix-asset-loading
Conflicts: js/src/app.js js/yoast-acf-analysis.js
- Loading branch information
Showing
17 changed files
with
456 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,67 @@ | ||
module.exports = function(){ | ||
return _.map(acf.get_fields(), function(field){ | ||
|
||
var outerFieldsName = [ | ||
'flexible_content', | ||
'repeater', | ||
'group' | ||
]; | ||
|
||
var innerFields = []; | ||
var outerFields = []; | ||
|
||
var fields = _.map(acf.get_fields(), function(field){ | ||
|
||
var field_data = jQuery.extend( true, {}, acf.get_data(jQuery(field)) ); | ||
field_data.$el = jQuery(field); | ||
field_data.post_meta_key = field_data.name; | ||
|
||
// Collect nested and parent | ||
if( outerFieldsName.indexOf(field_data.type) === -1 ) { | ||
innerFields.push(field_data); | ||
}else{ | ||
outerFields.push(field_data); | ||
} | ||
|
||
return field_data; | ||
|
||
}); | ||
}; | ||
|
||
if( outerFields.length === 0){ | ||
return fields; | ||
} | ||
|
||
// Transform field names for nested fields. | ||
_.each(innerFields, function(inner){ | ||
|
||
_.each(outerFields, function(outer){ | ||
|
||
if (jQuery.contains(outer.$el[0], inner.$el[0])) { | ||
|
||
// Types that hold multiple children. | ||
if (outer.type === 'flexible_content' || outer.type === 'repeater'){ | ||
|
||
outer.children = outer.children || []; | ||
outer.children.push(inner); | ||
inner.parent = outer; | ||
inner.post_meta_key = outer.name + '_' + (outer.children.length - 1) + '_' + inner.name; | ||
|
||
} | ||
|
||
// Types that hold single children. | ||
if (outer.type === 'group') { | ||
|
||
outer.children = [inner]; | ||
inner.parent = outer; | ||
inner.post_meta_key = outer.name + '_' + inner.name; | ||
|
||
} | ||
|
||
} | ||
|
||
}); | ||
|
||
}); | ||
|
||
return fields; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.