Advertisement
eventsmanager

Custom Conditional Placeholder for Event Attribute

Jun 12th, 2013
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. {is_true} show this message {/is_true}
  5. */
  6.  
  7. function my_em_has_attribute_event_output_condition($replacement, $condition, $match, $EM_Event){
  8. if( is_object($EM_Event) && preg_match('/^is_true/',$condition, $matches) ){
  9. if( !in_array($args['attribute_name'],$EM_Event->event_attributes) && !empty($EM_Event->event_attributes['attribute_name']) ){
  10. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  11. }else{
  12. $replacement = '';
  13. }
  14. }
  15. return $replacement;
  16. }
  17. add_action('em_event_output_condition', 'my_em_has_attribute_event_output_condition', 1, 4);
  18.  
  19. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement