eventsmanager

Custom Default Full calendar - shows future events only

Jun 27th, 2014 (edited)
832
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. * This file contains the HTML generated for full calendars. You can copy this file to yourthemefolder/plugins/events-manager/templates and modify it in an upgrade-safe manner.
  4. *
  5. * There are two variables made available to you:
  6. *
  7. * $calendar - contains an array of information regarding the calendar and is used to generate the content
  8. * $args - the arguments passed to EM_Calendar::output()
  9. *
  10. * Note that leaving the class names for the previous/next links will keep the AJAX navigation working.
  11. */
  12. $cal_count = count($calendar['cells']); //to prevent an extra tr
  13. $col_count = $tot_count = 1; //this counts collumns in the $calendar_array['cells'] array
  14. $col_max = count($calendar['row_headers']); //each time this collumn number is reached, we create a new collumn, the number of cells should divide evenly by the number of row_headers
  15. ?>
  16. <table class="em-calendar fullcalendar">
  17. <thead>
  18. <tr>
  19. <td><a class="em-calnav full-link em-calnav-prev" href="<?php echo $calendar['links']['previous_url']; ?>">&lt;&lt;</a></td>
  20. <td class="month_name" colspan="5"><?php echo ucfirst(date_i18n(get_option('dbem_full_calendar_month_format'), $calendar['month_start'])); ?></td>
  21. <td><a class="em-calnav full-link em-calnav-next" href="<?php echo $calendar['links']['next_url']; ?>">&gt;&gt;</a></td>
  22. </tr>
  23. </thead>
  24. <tbody>
  25. <tr class="days-names">
  26. <td><?php echo implode('</td><td>',$calendar['row_headers']); ?></td>
  27. </tr>
  28. <tr>
  29. <?php
  30. foreach($calendar['cells'] as $date => $cell_data ){
  31.  
  32. $class = ( !empty($cell_data['events']) && count($cell_data['events']) > 0 ) ? 'eventful':'eventless';
  33. if(!empty($cell_data['type'])){
  34. $class .= "-".$cell_data['type'];
  35. }
  36. //In some cases (particularly when long events are set to show here) long events and all day events are not shown in the right order. In these cases,
  37. //if you want to sort events cronologically on each day, including all day events at top and long events within the right times, add define('EM_CALENDAR_SORTTIME', true); to your wp-config.php file
  38. if( defined('EM_CALENDAR_SORTTIME') && EM_CALENDAR_SORTTIME ) ksort($cell_data['events']); //indexes are timestamps
  39. ?>
  40. <td class="<?php echo $class; ?>">
  41.  
  42. <?php foreach ($cell_data['events'] as $EM_Event): ?>
  43. <?php if ($EM_Event->start >= current_time('timestamp')): ?>
  44. <a href="<?php echo esc_url($cell_data['link']); ?>" title="<?php echo esc_attr($cell_data['link_title']); ?>"><?php echo date('j',$cell_data['date']); ?></a>
  45. <ul>
  46. <?php echo EM_Events::output($cell_data['events'],array('format'=>get_option('dbem_full_calendar_event_format'))); ?>
  47. <?php if( $args['limit'] && $cell_data['events_count'] > $args['limit'] && get_option('dbem_display_calendar_events_limit_msg') != '' ): ?>
  48. <li><a href="<?php echo esc_url($cell_data['link']); ?>"><?php echo get_option('dbem_display_calendar_events_limit_msg'); ?></a></li>
  49. <?php endif; ?>
  50. </ul>
  51. <?php break; ?>
  52. <?php else: ?>
  53. <?php echo date('j',$cell_data['date']); ?>
  54. <?php break; ?>
  55. <?php endif; ?>
  56. <?php endforeach; ?>
  57.  
  58.  
  59. <?php if( !empty($cell_data['events']) && count($cell_data['events']) > 0 ): ?>
  60.  
  61. <?php else:?>
  62. <?php echo date('j',$cell_data['date']); ?>
  63. <?php endif; ?>
  64.  
  65.  
  66.  
  67. </td>
  68. <?php
  69. //create a new row once we reach the end of a table collumn
  70. $col_count= ($col_count == $col_max ) ? 1 : $col_count+1;
  71. echo ($col_count == 1 && $tot_count < $cal_count) ? '</tr><tr>':'';
  72. $tot_count ++;
  73. }
  74. ?>
  75. </tr>
  76. </tbody>
  77. </table>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×