Created
May 6, 2012 15:42
-
-
Save jeremyboggs/2622991 to your computer and use it in GitHub Desktop.
Illustrates how to use new filter in ScholarPress Coins 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 | |
function my_custom_coins_title($coinsTitle) | |
{ | |
global $post; | |
// Starts the coins title value again. | |
$coinsTitle = 'ctx_ver=Z39.88-2004' | |
. '&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc' | |
. '&rfr_id=info%3Asid%2Focoins.info%3Agenerator' | |
. '&rft.type=' | |
. '&rft.format=text' | |
. '&rft.title='.urlencode($post->post_title) | |
. '&rft.source='.urlencode(get_bloginfo('name')) | |
. '&rft.date='.get_the_time('Y-m-d') | |
. '&rft.identifier='.urlencode(get_permalink($post->ID)) | |
. '&rft.language=English'; | |
if ($cats = get_the_category()) { | |
foreach((get_the_category()) as $cat) { | |
$coinsTitle .= '&rft.subject='.urlencode($cat->cat_name); | |
} | |
} | |
// Custom post metadata for author field. | |
$authors = get_post_custom_values('author'); | |
if ($authors) { | |
foreach($authors as $author) { | |
$coinsTitle .= '&rft.au='.urlencode($author); | |
} | |
} | |
return $coinsTitle; | |
} | |
add_filter('scholarpress_coins_span_title', 'my_custom_coins_title'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment