admin-calendar.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <section id="booked-plugin-page" class="booked-admin-calendar-page-wrap">
  2. <div id="data-ajax-url"><?php echo get_admin_url(); ?></div>
  3. <?php
  4. $calendars = get_terms('booked_custom_calendars','orderby=slug&hide_empty=0');
  5. $booked_none_assigned = true;
  6. $default_calendar_id = false;
  7. $noTopBar = false;
  8. if (!empty($calendars)):
  9. if (!current_user_can('manage_booked_options')):
  10. $booked_current_user = wp_get_current_user();
  11. $calendars = booked_filter_agent_calendars($booked_current_user,$calendars);
  12. if (!empty($calendars)):
  13. $first_calendar = array_slice($calendars, 0, 1);
  14. $default_calendar_id = array_shift($first_calendar)->term_id;
  15. $booked_none_assigned = false;
  16. endif;
  17. else:
  18. $booked_none_assigned = false;
  19. endif;
  20. if (!$booked_none_assigned && count($calendars) >= 1):
  21. ?><div class="booked-calendarSwitcher"><p>
  22. <i class="booked-icon booked-icon-calendar"></i><?php
  23. echo '<select name="bookedCalendarDisplayed">';
  24. if (current_user_can('manage_booked_options')): echo '<option value="">'.esc_html__('All Calendars','booked').'</option>'; endif;
  25. foreach($calendars as $calendar):
  26. ?><option value="<?php echo $calendar->term_id; ?>"><?php echo $calendar->name; ?></option><?php
  27. endforeach;
  28. echo '</select>';
  29. ?></p></div><?php
  30. else :
  31. $noTopBar = true;
  32. ?><div class="noCalendarsSpacer"></div><?php
  33. endif;
  34. else :
  35. $noTopBar = true;
  36. ?><div class="noCalendarsSpacer"></div><?php
  37. endif;
  38. if (!current_user_can('manage_booked_options') && $booked_none_assigned):
  39. echo '<div style="text-align:center;">';
  40. echo '<br><br><h3>'.esc_html__('There are no calendars assigned to you.','booked').'</h3>';
  41. echo '<p>'.esc_html__('Get in touch with the Administration of this site to get a calendar assigned to you.','booked').'</p>';
  42. echo '</div>';
  43. else:
  44. ?><div class="booked-admin-calendar-wrap<?php echo ($noTopBar ? ' noTopBar' : ''); ?>">
  45. <?php booked_admin_calendar(false,false,$default_calendar_id); ?>
  46. </div><?php
  47. endif; ?>
  48. </section>