forked from Yoast/yoast-acf-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yoast#97 Add support for Page Link Field
- Loading branch information
Showing
4 changed files
with
76 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* 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() | ||
|
||
field.content = "<a href=\"/?p=" + url + "\">" + title + "</a>"; | ||
|
||
return field; | ||
} ); | ||
}; | ||
|
||
module.exports = Scraper; |
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