Advertisement
eventsmanager

Conditional Placeholder: has_spaces_x

Sep 15th, 2014
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. /*
  2.  
  3. This custom conditional placeholder shows the format per booking spaces available
  4.  
  5. sample usage:
  6. {has_spaces_100}
  7. #_EVENTNAME
  8. {/has_spaces_100}
  9. */
  10. add_action('em_event_output_condition', 'my_em_custom_event_output_condition', 1, 4);
  11. function my_em_custom_event_output_condition($replacement, $condition, $match, $EM_Event){
  12. if( is_object($EM_Event) && preg_match('/^has_spaces_([a-zA-Z0-9_\-]+)$/',$condition, $matches) ){
  13.  
  14. $booking_space = $EM_Event->get_bookings()->get_available_spaces();
  15.  
  16. if( $booking_space <= $matches[1] ){
  17. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  18. }else{
  19. $replacement = '';
  20. }
  21. }
  22. return $replacement;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement