Advertisement
Guest User

plugin:Events-Manager Show Recurring Evnts Once

a guest
Apr 5th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement