Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function em_get_events_list_shortcode_all($atts, $format='') {
- $atts = (array) $atts;
- $atts['format'] = ($format != '' || empty($atts['format'])) ? $format : $atts['format'];
- $atts['format'] = html_entity_decode($atts['format']); //shorcode doesn't accept html
- $atts['page'] = ( !empty($atts['page']) && is_numeric($atts['page']) )? $atts['page'] : 1;
- $atts['page'] = ( !empty($_GET['page']) && is_numeric($_GET['page']) )? $_GET['page'] : $atts['page'];
- // get recurrence events
- $atts['recurring']=1;
- $evts_recurring=EM_Events::get($atts);
- // get non-recurrence events
- $atts['recurring']=0;
- $evts=EM_Events::get($atts);
- // filter out the events that are instances of recurring events
- $non_recurrence_evts = array_filter($evts,'is_no_recurrence');
- // merge recurrence and non-recurring events
- $evts_all= array_merge($non_recurrence_evts,$evts_recurring);
- // sort them by start==start date+time
- usort($evts_all,'evt_start_sort');
- //
- return EM_Events::output( $evts_all, $atts );
- }
- add_shortcode ( 'events_list_all', 'em_get_events_list_shortcode_all' );
- function is_no_recurrence($evt) {
- return $evt->recurrence_id == null;
- }
- function evt_start_sort($evt1, $evt2) {
- return $evt1->start > $evt2->start;
- }
- // ... for the display - a conditional placeholder
- function filter_condition($show_condition, $condition, $conditionals_key, $thiss) {
- if ($condition == "is_recurring") {
- $show_condition=$thiss->recurrence == 1;
- }
- return $show_condition;
- }
- add_filter('em_event_output_show_condition', 'filter_condition',10,4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement