Want more features on Pastebin? Sign Up, it's FREE!
Guest

plugin:Events-Manager Recurring Events Show Once

By: a guest on Apr 5th, 2012  |  syntax: PHP  |  size: 1.67 KB  |  views: 154  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function em_get_events_list_shortcode_all($atts, $format='') {
  2.         $atts = (array) $atts;
  3.         $atts['format'] = ($format != '' || empty($atts['format'])) ? $format : $atts['format'];
  4.         $atts['format'] = html_entity_decode($atts['format']); //shorcode doesn't accept html
  5.         $atts['page'] = ( !empty($atts['page']) && is_numeric($atts['page']) )? $atts['page'] : 1;
  6.         $atts['page'] = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : $atts['page'];        
  7.  
  8.         // get recurrence events
  9.         $atts['recurring']=1;
  10.         $evts_recurring=EM_Events::get($atts);
  11.  
  12.         // get non-recurrence events
  13.         $atts['recurring']=0;
  14.         $evts=EM_Events::get($atts);
  15.         // filter out the events that are instances of recurring events
  16.         $non_recurrence_evts = array_filter($evts,'is_no_recurrence');
  17.  
  18.         // merge recurrence and non-recurring events
  19.         $evts_all= array_merge($non_recurrence_evts,$evts_recurring);
  20.         // sort them by start==start date+time
  21.         usort($evts_all,'evt_start_sort');
  22.  
  23.         //
  24.         return EM_Events::output( $evts_all, $atts );
  25. }
  26. add_shortcode ( 'events_list_all', 'em_get_events_list_shortcode_all' );
  27.  
  28. function is_no_recurrence($evt) {
  29.     return $evt->recurrence_id == null;
  30. }
  31.  
  32. function evt_start_sort($evt1, $evt2) {
  33.     return $evt1->start > $evt2->start;
  34. }
  35.  
  36.  
  37. // ... for the display - a conditional placeholder
  38. function filter_condition($show_condition, $condition, $conditionals_key, $thiss) {
  39.  
  40.     if ($condition == "is_recurring") {
  41.         $show_condition=$thiss->recurrence == 1;
  42.     }
  43.     return $show_condition;
  44. }
  45. add_filter('em_event_output_show_condition', 'filter_condition',10,4);
clone this paste RAW Paste Data