Last active
August 18, 2016 20:21
-
-
Save stephanieleary/5ff713797644043a9546c850011ecc77 to your computer and use it in GitHub Desktop.
Example filters to add or edit custom fields for the Citation Importer plugin.
This file contains hidden or 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
<?php | |
/* | |
Plugin Name: Citation Importer Filters | |
Plugin URI: http://stephanieleary.com/ | |
Description: Add or edit fields for the Citation Importer. | |
Author: sillybean | |
Author URI: http://stephanieleary.com/ | |
Version: 0.1 | |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
*/ | |
add_filter( 'citation_importer_fielddata', 'filter_citation_importer_source_fields', 10, 3 ); | |
function filter_citation_importer_source_fields( $fields, $post, $item ) { | |
$fields['source'] = sanitize_text_field( $item['container-title'][0] ); | |
if ( isset( $item['volume'] ) && !empty( $item['volume'] ) ) | |
$fields['volume'] = sanitize_text_field( $item['volume'] ); | |
if ( isset( $item['issue'] ) &&!empty( $item['issue'] ) ) | |
$fields['issue'] = sanitize_text_field( $item['issue'] ); | |
if ( isset( $item['page'] ) &&!empty( $item['page'] ) ) | |
$fields['page'] = sanitize_text_field( $item['page'] ); | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment