Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- New conditional placeholder for events category has events
- USAGE:
- <ul>
- [categories_list hide_empty=1]
- {has_upcoming_events}
- <li>#_CATEGORYLINK</li>
- {/has_upcoming_events}
- [/categories_list]
- </ul>
- */
- add_action('em_category_output_condition', 'my_em_category_output_condition', 1, 4);
- function my_em_category_output_condition($replacement, $condition, $match, $EM_Category){
- if( is_object($EM_Category) && preg_match('/^has_upcoming_events$/',$condition, $matches) ){
- if( EM_Events::count(array('scope'=>'future','category'=>$EM_Category->term_id)) > 0 ){
- $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
- }else{
- $replacement = '';
- }
- }
- return $replacement;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement