Skip to content

Commit

Permalink
Merge pull request #2 from htmlburger/fix/complex
Browse files Browse the repository at this point in the history
Fix the way complex field values are parsed and used by Yoast
  • Loading branch information
jorostoyanov authored Mar 7, 2019
2 parents 397c36a + dd88c57 commit 9fceee8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions js/carbon-fields-yoast.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var CarbonFieldsYoast = (function($) {

var CarbonFieldsYoast = function(params) {
params = params || {};

this.carbonFieldsVersion;

if (window.hasOwnProperty('cf')) {
Expand Down Expand Up @@ -47,7 +49,7 @@ var CarbonFieldsYoast = (function($) {
/**
* Add names of fields you wish to ignore to this array
*/
this.fieldsByNameToExclude = this.fieldsByNameToExclude || [];
this.fieldsByNameToExclude = params.fieldsByNameToExclude || [];

YoastSEO.app.registerPlugin('CarbonFieldsYoastPlugin', {
status: 'ready'
Expand Down Expand Up @@ -91,15 +93,7 @@ var CarbonFieldsYoast = (function($) {
};

CarbonFieldsYoast.prototype.getFieldContent = function (field) {
var fieldContent;

if (field.type === 'rich_text') {
fieldContent = $(field.value).text();
} else {
fieldContent = field.value;
}

return fieldContent;
return field.value;
};

CarbonFieldsYoast.prototype.invokeUpdate = function () {
Expand All @@ -122,6 +116,12 @@ var CarbonFieldsYoast = (function($) {
}

$.each(fields, function (index, field) {
// we can skip complex fields, as their children are
// already present in the main fields array
if (field.type === 'complex') {
return;
}

fieldsContentParts.push(_self.getFieldContent(field));
});

Expand Down

0 comments on commit 9fceee8

Please sign in to comment.