コード例 #1
0
ファイル: Main.php プロジェクト: TravisSperry/mpa_website
 /**
  * Add custom query modification to the pre_get_posts hook as necessary for PRO.
  *
  * @param WP_Query $query The current query object.
  *
  * @return WP_Query The modified query object.
  */
 public function pre_get_posts($query)
 {
     if ($query->is_single() && $query->get('eventDate')) {
         $this->set_post_id_for_recurring_event_query($query);
     }
     if (!empty($query->tribe_is_event_pro_query)) {
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $start_date = tribe_get_first_week_day($query->get('eventDate'));
                 $end_date = tribe_get_last_week_day($start_date);
                 // if the setting to hide weekends is true
                 if (tribe_get_option('week_view_hide_weekends', false) == true) {
                     $start_of_week = get_option('start_of_week');
                     // check if the week is set to start on a weekend day
                     // If so, start on the next weekday.
                     // 0 = Sunday, 6 = Saturday
                     if ($start_of_week == 0 || $start_of_week == 6) {
                         $start_date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime($start_date . ' +1 Weekday'));
                     }
                     // If the week starts on saturday or friday
                     // sunday and/or saturday would be on the other end, so we need to end the previous weekday
                     // 5 = Friday, 6 = Saturday
                     if ($start_of_week == 5 || $start_of_week == 6) {
                         $end_date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime($end_date . ' -1 Weekday'));
                     }
                 }
                 // if the setting to hide weekends is on
                 // need to filter the query
                 // need to only show 5 days on the week view
                 // if we're using an non-default hour range on week view
                 if (has_filter('tribe_events_week_get_hours')) {
                     $start_date .= ' ' . tribe_events_week_get_hours('first-hour');
                     $end_date .= ' ' . tribe_events_week_get_hours('last-hour');
                 }
                 $query->set('eventDate', $start_date);
                 $query->set('start_date', $start_date);
                 $query->set('end_date', $end_date);
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'photo':
                 $query->set('hide_upcoming', false);
                 break;
             case 'all':
                 new Tribe__Events__Pro__Recurrence__Event_Query($query);
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }
コード例 #2
0
<?php

/**
 * Week View Grid Hourly Event Loop
 * This file sets up the structure for the week grid hourly event loop
 *
 * Override this template in your own theme by creating a file at [your-theme]/tribe-events/week/loop-grid-hourly.php
 *
 * @package TribeEventsCalendar
 *
 */
if (!defined('ABSPATH')) {
    die('-1');
}
$hours = tribe_events_week_get_hours();
?>
<div class="tribe-week-grid-wrapper tribe-scroller">
	<div class="scroller-content">
		<div class="tribe-week-grid-outer-wrap tribe-clearfix">
			<div class="tribe-week-grid-inner-wrap">
				<?php 
foreach ($hours as $hour => $formatted_hour) {
    ?>
					<div class="tribe-week-grid-block" data-hour="<?php 
    echo esc_attr($hour);
    ?>
">
						<div></div>
					</div>
				<?php 
}
コード例 #3
0
ファイル: Week.php プロジェクト: TakenCdosG/chefs
 /**
  * Account for :30 EOD cutoffs, which break week view
  *
  * @param        $date
  * @param string $format
  *
  * @return bool|string
  */
 protected static function get_rounded_end_of_day($date, $format = 'U')
 {
     $end_of_day = (int) tribe_end_of_day($date, 'U') + 1;
     end(self::$hour_range);
     $date = min($end_of_day, strtotime($date . ' ' . tribe_events_week_get_hours('last-hour')));
     $date = date('Y-m-d H:00:00', $date);
     $date = date($format, strtotime($date));
     return $date;
 }
コード例 #4
0
ファイル: Main.php プロジェクト: simple-beck/project-gc
 /**
  * Add custom query modification to the pre_get_posts hook as necessary for PRO.
  *
  * @param WP_Query $query The current query object.
  *
  * @return WP_Query The modified query object.
  */
 public function pre_get_posts($query)
 {
     if ($query->is_single() && $query->get('eventDate')) {
         $this->set_post_id_for_recurring_event_query($query);
     }
     if (!empty($query->tribe_is_event_pro_query)) {
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $start_date = tribe_get_first_week_day($query->get('eventDate'));
                 $end_date = tribe_get_last_week_day($start_date);
                 // if the setting to hide weekends is true
                 if (tribe_get_option('week_view_hide_weekends', false) == true) {
                     $start_of_week = get_option('start_of_week');
                     // check if the week is set to start on a weekend day
                     // If so, start on the next weekday.
                     // 0 = Sunday, 6 = Saturday
                     if ($start_of_week == 0 || $start_of_week == 6) {
                         $start_date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime($start_date . ' +1 Weekday'));
                     }
                     // If the week starts on saturday or friday
                     // sunday and/or saturday would be on the other end, so we need to end the previous weekday
                     // 5 = Friday, 6 = Saturday
                     if ($start_of_week == 5 || $start_of_week == 6) {
                         $end_date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime($end_date . ' -1 Weekday'));
                     }
                 }
                 // if the setting to hide weekends is on
                 // need to filter the query
                 // need to only show 5 days on the week view
                 // if we're using an non-default hour range on week view
                 if (has_filter('tribe_events_week_get_hours')) {
                     $start_date .= ' ' . tribe_events_week_get_hours('first-hour');
                     $end_date .= ' ' . tribe_events_week_get_hours('last-hour');
                 }
                 $query->set('eventDate', $start_date);
                 $query->set('start_date', $start_date);
                 $query->set('end_date', $end_date);
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'photo':
                 $query->set('hide_upcoming', false);
                 break;
             case 'all':
                 $slug = $query->get('name');
                 if (empty($slug)) {
                     break;
                     // we shouldn't be here
                 }
                 unset($query->query_vars['name']);
                 unset($query->query_vars['tribe_events']);
                 $posts = get_posts(array('name' => $slug, 'post_type' => Tribe__Events__Main::POSTTYPE, 'post_status' => 'publish', 'numberposts' => 1));
                 $post = reset($posts);
                 if (empty($post)) {
                     $query->set('p', -1);
                 } else {
                     $query->set('post_parent', $post->ID);
                     $query->set('post_status', 'publish');
                     $query->set('posts_per_page', tribe_get_option('postsPerPage', 10));
                     $query->is_singular = false;
                 }
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }