eventsmanager

Conditional Placeholder: has_spaces_x

Sep 15th, 2014
499
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×