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

#97 Add support for Page Link Field #230

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion inc/ac-yoast-seo-acf-content-analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ protected function get_blacklist_type() {
'true_false',

'post_object',
'page_link',
'relationship',
'user',

Expand Down
1 change: 1 addition & 0 deletions js/src/scraper-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var scraperObjects = {
// TODO: select, checkbox, radio

// Relational
page_link: require( "./scraper/scraper.page_link.js" ),
taxonomy: require( "./scraper/scraper.taxonomy.js" ),

// Third-party / jQuery
Expand Down
34 changes: 34 additions & 0 deletions js/src/scraper/scraper.page_link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* global _ */
require( "../scraper-store.js" );

var Scraper = function() {};

/**
* Scraper for the page link field type.
*
* @param {Object} fields Fields to parse.
*
* @returns {Object} Mapped list of fields.
*/
Scraper.prototype.scrape = function( fields ) {
/**
* Set content for all page link fields as a-tag with title, url and target.
* Return the fields object containing all fields.
*/
return _.map( fields, function( field ) {
if ( field.type !== "page_link" ) {
return field;
}

var title = field.$el.find( "select option:selected" ).text(),
postId = field.$el.find("select option:selected").val()

if (title && postId) {
field.content = "<a href=\"/?p=" + url + "\">" + title + "</a>";
}

return field;
} );
};

module.exports = Scraper;
48 changes: 43 additions & 5 deletions js/yoast-acf-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ var scraperObjects = {
// TODO: select, checkbox, radio

// Relational
page_link: require( "./scraper/scraper.page_link.js" ),
taxonomy: require( "./scraper/scraper.taxonomy.js" ),

// Third-party / jQuery
Expand Down Expand Up @@ -545,7 +546,7 @@ module.exports = {
getScraper: getScraper,
};

},{"./config/config.js":7,"./scraper/scraper.email.js":12,"./scraper/scraper.gallery.js":13,"./scraper/scraper.image.js":14,"./scraper/scraper.link.js":15,"./scraper/scraper.taxonomy.js":16,"./scraper/scraper.text.js":17,"./scraper/scraper.textarea.js":18,"./scraper/scraper.url.js":19,"./scraper/scraper.wysiwyg.js":20}],12:[function(require,module,exports){
},{"./config/config.js":7,"./scraper/scraper.email.js":12,"./scraper/scraper.gallery.js":13,"./scraper/scraper.image.js":14,"./scraper/scraper.link.js":15,"./scraper/scraper.page_link.js":16,"./scraper/scraper.taxonomy.js":17,"./scraper/scraper.text.js":18,"./scraper/scraper.textarea.js":19,"./scraper/scraper.url.js":20,"./scraper/scraper.wysiwyg.js":21}],12:[function(require,module,exports){
/* global _ */

var Scraper = function() {};
Expand Down Expand Up @@ -682,6 +683,43 @@ Scraper.prototype.scrape = function( fields ) {
module.exports = Scraper;

},{"./../scraper-store.js":11}],16:[function(require,module,exports){
/* global _ */
require( "../scraper-store.js" );

var Scraper = function() {};

/**
* Scraper for the page link field type.
*
* @param {Object} fields Fields to parse.
*
* @returns {Object} Mapped list of fields.
*/
Scraper.prototype.scrape = function( fields ) {
/**
* Set content for all page link fields as a-tag with title, url and target.
* Return the fields object containing all fields.
*/
return _.map( fields, function( field ) {
if ( field.type !== "page_link" ) {
return field;
}

var title = field.$el.find( "select option:selected" ).text(),
url = field.$el.find( "input[type=hidden].input-url" ).val(),
target = field.$el.find( "input[type=hidden].input-target" ).val();

console.log(title, url, target)

field.content = "<a href=\"" + url + "\" target=\"" + target + "\">" + title + "</a>";

return field;
} );
};

module.exports = Scraper;

},{"../scraper-store.js":11}],17:[function(require,module,exports){
/* global _, acf */

var Scraper = function() {};
Expand Down Expand Up @@ -737,7 +775,7 @@ Scraper.prototype.scrape = function( fields ) {

module.exports = Scraper;

},{}],17:[function(require,module,exports){
},{}],18:[function(require,module,exports){
/* global _ */

var config = require( "./../config/config.js" );
Expand Down Expand Up @@ -792,7 +830,7 @@ Scraper.prototype.isHeadline = function( field ) {

module.exports = Scraper;

},{"./../config/config.js":7}],18:[function(require,module,exports){
},{"./../config/config.js":7}],19:[function(require,module,exports){
/* global _ */

var Scraper = function() {};
Expand All @@ -813,7 +851,7 @@ Scraper.prototype.scrape = function( fields ) {

module.exports = Scraper;

},{}],19:[function(require,module,exports){
},{}],20:[function(require,module,exports){
/* global _ */

var Scraper = function() {};
Expand All @@ -836,7 +874,7 @@ Scraper.prototype.scrape = function( fields ) {

module.exports = Scraper;

},{}],20:[function(require,module,exports){
},{}],21:[function(require,module,exports){
/* global tinyMCE, _ */

var Scraper = function() {};
Expand Down