Skip to content

Instantly share code, notes, and snippets.

@jeremyboggs
Created May 6, 2012 15:42
Show Gist options
  • Save jeremyboggs/2622991 to your computer and use it in GitHub Desktop.
Save jeremyboggs/2622991 to your computer and use it in GitHub Desktop.
Illustrates how to use new filter in ScholarPress Coins plugin
<?php
function my_custom_coins_title($coinsTitle)
{
global $post;
// Starts the coins title value again.
$coinsTitle = 'ctx_ver=Z39.88-2004'
. '&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc'
. '&amp;rfr_id=info%3Asid%2Focoins.info%3Agenerator'
. '&amp;rft.type='
. '&amp;rft.format=text'
. '&amp;rft.title='.urlencode($post->post_title)
. '&amp;rft.source='.urlencode(get_bloginfo('name'))
. '&amp;rft.date='.get_the_time('Y-m-d')
. '&amp;rft.identifier='.urlencode(get_permalink($post->ID))
. '&amp;rft.language=English';
if ($cats = get_the_category()) {
foreach((get_the_category()) as $cat) {
$coinsTitle .= '&amp;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 .= '&amp;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