Advertisement
eventsmanager

custom conditional placeholder

Jul 18th, 2013
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. function em_mod_offline_conditional($replacement, $condition, $match, $EM_Event){
  2. if (is_object($EM_Event)) {
  3. switch ($condition) {
  4. case 'has_offline':
  5. $count_offline = 0;
  6. foreach($EM_Event->get_bookings() as $EM_Booking){
  7. $current_booking_id = $EM_Booking->output('#_BOOKINGID');
  8. if ( $EM_Booking->booking_meta['gateway'] == 'offline' && $current_booking_id == $EM_Booking->booking_id ){
  9. $count_offline++;
  10. }
  11. }
  12. if ( $count_offline > 0 ){
  13. $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
  14. }else{
  15. $replacement = '';
  16. }
  17. break;
  18. }
  19. }
  20. return $replacement;
  21. }
  22. add_filter('em_event_output_condition', 'em_mod_offline_conditional', 10, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement