Advertisement
BakerMan

TEC/ECP post_class filter issue

Dec 14th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. /**
  2.  * Removes the Tribe post_class filter on the first occasion that filter is
  3.  * used, then sets it up again for future calls.
  4.  *
  5.  * @param array $classes
  6.  * @return array
  7.  */
  8. function remove_tribe_cat_once(array $classes) {
  9.     static $count = 0;
  10.  
  11.     if ($count++ === 0) {
  12.         remove_filter('post_class', array(TribeEvents::instance(), 'post_class'));
  13.     }
  14.     else {
  15.         add_filter('post_class', array(TribeEvents::instance(), 'post_class'));
  16.         remove_filter('post_class', 'remove_tribe_cat_once');
  17.     }
  18.  
  19.     return $classes;
  20. }
  21.  
  22. // Try to stop the first event category from being added to the article classes
  23. // (when the default page template is used)
  24. add_filter('post_class', 'remove_tribe_cat_once', 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement