Advertisement
Guest User

Untitled

a guest
May 30th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Add support for serial commas to Co-Authors Plus WordPress plugin.
  5. *
  6. * Filters coauthors_default_between_last to support serial commas, aka oxford commas, for 3 or more coauthors
  7. * ex: By Samantha Larson, Darby Minow Smith, and David Roberts
  8. * ex: By Samantha Larson and Darby Minow Smith
  9. */
  10. add_filter( 'coauthors_default_between_last', function( $between_last ) {
  11. // only be concerned with commas with ' and ' which is CAP's default value
  12. if ( ' and ' !== $between_last )
  13. return $between_last;
  14. // prefix a comma if there are more than two coauthors
  15. $coauthors = get_coauthors();
  16. if ( count( $coauthors ) > 2 )
  17. return ', and ';
  18. else
  19. return ' and ';
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement