Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // sample usage: {has_category_parent} content {/has_category_parent}
- add_action('em_event_output_condition', 'my_em_custom_category_has_parent', 100, 4);
- function my_em_custom_category_has_parent($replacement, $condition, $match, $EM_Event){
- if ( preg_match('/^has_category_parent$/',$condition, $matches) ){
- $count_cats = count($EM_Event->get_categories()->categories) > 0;
- if( $count_cats <= 1 ){
- foreach($EM_Event->get_categories() as $EM_Category){
- if( $EM_Category->parent > 0){
- $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
- }else{
- $replacement = '';
- }
- }
- }else{
- $replacement = '';
- }
- }
- return $replacement;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement