SHARE
TWEET

Conditional Placeholder: has_spaces_x

eventsmanager Sep 15th, 2014 405 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top