SHARE
TWEET

Display only recurring event

eventsmanager Jul 11th, 2019 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  this snippet will only display single recurrences
  3.  
  4.  usage: [events_list scope="future" limit=0 recurring_only=1]
  5.  
  6.  */
  7. add_filter('em_events_get_default_search','my_em_styles_get_default_search_hide_recurr',1,2);
  8. function my_em_styles_get_default_search_hide_recurr($searches, $array){
  9.     if( !empty($array['recurring_only']) ){
  10.         $searches['recurring_only'] = $array['recurring_only'];
  11.     }
  12.     return $searches;
  13. }
  14.  
  15. add_filter('em_events_get','my_em_hide_recurr',1,2);
  16. function my_em_hide_recurr($events, $args){
  17.     if( !empty($args['recurring_only']) && is_numeric($args['recurring_only']) ){
  18.         $recurring_set    = array();
  19.         foreach($events as $event_key => $EM_Event){
  20.            
  21.             $event_start_date = Date('Y-m-d', strtotime($EM_Event->event_start_date) );
  22.             $now              = Date('Y-m-d');
  23.            
  24.            
  25.             if ( !$EM_Event->is_recurrence()  ){
  26.                 unset($events[$event_key]);
  27.             }else{
  28.                 if ( !in_array( $EM_Event->event_name , $recurring_set ) && $event_start_date > $now ){
  29.                    array_push( $recurring_set, $EM_Event->event_name );
  30.                 }else{
  31.                     unset($events[$event_key]);
  32.                 }
  33.             }
  34.            
  35.         }
  36.     }
  37.     return $events;
  38. }
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