The WordPress Citation Importer plugin imports individual citations, bibliography lists, or lists of DOIs into WordPress via the CrossRef Metadata API. Using a publication post type and/or a few custom fields, you could build a local database of publications for your company, university, library, etc. without having to manually enter each field.
How it works
1. Enter citations into the editor and select which post type should be the destination.
2. See if crossref.org‘s API found the correct publication(s). (The importer returns only the first match for each citation.) If not, you can run your own search to find the correct DOIs and enter them into the previous screen.
3. Edit the imported data as needed. It will not be refreshed from crossref.org again after the initial import, so your corrections here will stick.
Filters
Your WordPress custom fields and taxonomies likely do not match those used by this importer. Therefore, the post fields, custom fields, and taxonomies are all filterable.
Post fields
Standard post fields (post_title, post_content, post_status, etc.) are stored in the $post array. The original data received from crossref.org is passed to you in the $item object.
apply_filters( 'citation_importer_postdata', $post, $item );
Custom fields
Custom fields are given in the $fields associative array, with the meta_key used as the array key and the meta_value as the value. The $post array contains the standard post fields, and the $item object contains the crossref.org data.
apply_filters( 'citation_importer_fielddata', $fields, $post, $item );
Taxonomies
Custom taxonomies are set in the $terms associative array, with the taxonomy name used as the array key and the term slug (or array of slugs) as the value. The $post array contains the standard post fields, and the $item object contains the crossref.org data.
apply_filters( 'citation_importer_termdata', $terms, $post, $item );
Example Filter Function
Here’s an example of a function that splits the source publication’s volume and issue into separate fields (instead of appending them to the title) and adds a field for the page numbers.
https://gist.github.com/sillybean/5ff713797644043a9546c850011ecc77
Running the importer with the above plugin activated (and the new fields defined in ACF), the publication pictured above now looks like this:
You could use the filters to split the authors into separate fields, access the various parsed dates, or import more data from the search results (like the ISSN or alternative ID). Visit any record on crossref.org and view its data as JSON to see all the available fields.
More about CrossRef
The CrossRef Metadata API is an amazing tool for matching formatted citations with their parsed equivalents in a central database.
CrossRef’s Metadata API does not yet include abstracts. You may be able to locate them fairly easily with the DOIs in hand; see this GitHub issue for details. When abstracts become available in the API’s response, they will be added to the plugin’s post data.
Download, donate, contribute
This plugin is available for download on wordpress.org, but it’s also a work in progress, and you can contribute on GitHub.
Want to fund further development? Donate via PayPal.
Leave a Reply