Advertisement
BakerMan

Kill Tribe leading pipes (and other title separators)

Sep 23rd, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. /**
  2.  * When something other than the Default Events Template is in use a trailing
  3.  * separator can be applied to single event titles ... this code aims to
  4.  * resolve that.
  5.  */
  6. add_filter('tribe_events_add_title', 'fix_leading_tribal_pipe', 20, 3);
  7.  
  8. function fix_leading_tribal_pipe($title, $prev, $sep) {
  9.     // We're only interested if the Default Events Template is *not* in play
  10.     if ('default' !== TribeEvents::instance()->getOption('tribeEventsTemplate')) return $title;
  11.  
  12.     // Confirmation: ensure separator is the first symbol (there will be a leading space)
  13.     if (1 !== strpos($title, $sep)) return $title;
  14.  
  15.     // Strip it (account for the leading space)
  16.     return substr($title, strlen($sep) + 1);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement