Created
July 31, 2012 18:10
-
-
Save jeremyboggs/3219048 to your computer and use it in GitHub Desktop.
Function to filter item_citation to account for multiple creators.
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 to filter item_citation to account for multiple creators. | |
*/ | |
function item_citation_multiple_creators($cite, $item) { | |
$cite = ''; | |
if ($creators = item('Dublin Core', 'Creator', array('all' => true), $item)) { | |
switch(count($creators)) { | |
case 1: | |
$cite .= $creators[0]; | |
break; | |
case 2: | |
$cite .= implode(' and ', $creators); | |
break; | |
case 3: | |
$cite .= $creators[0] . ', ' . $creators[1] . ', and ' . $creators[2]; | |
break; | |
default: | |
$cite .= $creators[0] . ' et. al.'; | |
break; | |
} | |
$cite = $cite . ', '; | |
} | |
if ($title = item('Dublin Core', 'Title', array(), $item)) { | |
$cite .= "“$title,” "; | |
} | |
if ($siteTitle = settings('site_title')) { | |
$cite .= "<em>$siteTitle</em>, "; | |
} | |
$cite .= "accessed " . date('F j, Y') . ", "; | |
$cite .= abs_item_uri($item); | |
return strip_formatting($cite); | |
} | |
add_filter('item_citation', 'item_citation_multiple_creators'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment