Beispiel #1
0
 function tribe_events_the_nav_attributes($direction = 'prev', $echo = true)
 {
     global $wp_query;
     $direction = $direction == 'prev' ? '-' : '+';
     $current_week = tribe_get_first_week_day($wp_query->get('start_date'));
     $attributes = sprintf(' data-week="%s" ', date('Y-m-d', strtotime($current_week . ' ' . $direction . '7 days')));
     if ($echo) {
         echo $attributes;
     } else {
         return $attributes;
     }
 }
Beispiel #2
0
 public function __construct()
 {
     parent::__construct();
     self::$prior_event_date = (object) array('EventStartDate' => null, 'EventEndDate' => null);
     self::$today = date_i18n('Y-m-d', strtotime('today'));
     self::$start_of_week_date = self::get_rounded_beginning_of_day(tribe_get_first_week_day(), 'Y-m-d H:i:s');
     self::$end_of_week_date = self::get_rounded_end_of_day(date('Y-m-d', strtotime(self::$start_of_week_date . ' +' . self::$week_length - 1 . ' days')), 'Y-m-d H:i:s');
     self::$start_of_week = get_option('start_of_week', 0);
     self::$day_cutoff_rounded = date('H:00', strtotime(self::$start_of_week_date));
     // save tribe bar args
     if (empty(self::$tribe_bar_args)) {
         foreach ($_REQUEST as $key => $value) {
             if ($value && strpos($key, 'tribe-bar-') === 0 && $key != 'tribe-bar-date') {
                 self::$tribe_bar_args[$key] = $value;
             }
         }
     }
 }
Beispiel #3
0
 public function __construct()
 {
     parent::__construct();
     self::$prior_event_date = (object) array('EventStartDate' => null, 'EventEndDate' => null);
     self::$today = date_i18n('Y-m-d', strtotime('today'));
     self::$start_of_week_date = tribe_get_first_week_day();
     self::$end_of_week_date = date_i18n('Y-m-d', strtotime('+' . self::$week_length - 1 . ' days', strtotime(self::$start_of_week_date)));
     self::$start_of_week = get_option('start_of_week', 0);
     // let's get this show on the road
     // self::set_current_day( self::$start_of_week );
     self::set_week_days();
     self::setup_loop();
     // save tribe bar args
     if (empty(self::$tribe_bar_args)) {
         foreach ($_REQUEST as $key => $value) {
             if ($value && strpos($key, 'tribe-bar-') === 0 && $key != 'tribe-bar-date') {
                 self::$tribe_bar_args[$key] = $value;
             }
         }
     }
 }
Beispiel #4
0
function get_events_title()
{
    global $wp_query;
    $title = '';
    $date_format = apply_filters('tribe_events_pro_page_title_date_format', 'l, F jS Y');
    if (tribe_is_month() && !is_tax()) {
        $title = sprintf(__('Events for %s', 'tribe-events-calendar'), date_i18n('F Y', strtotime(tribe_get_month_view_date())));
    } elseif (class_exists('Tribe__Events__Pro__Main') && tribe_is_week()) {
        $title = sprintf(__('Events for week of %s', 'tribe-events-calendar-pro'), date_i18n($date_format, strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
    } elseif (class_exists('Tribe__Events__Pro__Main') && tribe_is_day()) {
        $title = __('Events for', 'tribe-events-calendar-pro') . ' ' . date_i18n($date_format, strtotime($wp_query->get('start_date')));
    } elseif (class_exists('Tribe__Events__Pro__Main') && (tribe_is_map() || tribe_is_photo())) {
        if (tribe_is_past()) {
            $title = __('Past Events', 'tribe-events-calendar-pro');
        } else {
            $title = __('Upcoming Events', 'tribe-events-calendar-pro');
        }
    } elseif (tribe_is_list_view()) {
        $title = __('Upcoming Events', 'dt_themes');
    } elseif (is_single()) {
        $title = $wp_query->post->post_title;
    } elseif (tribe_is_month() && is_tax()) {
        $term_slug = $wp_query->query_vars['tribe_events_cat'];
        $term = get_term_by('slug', $term_slug, 'tribe_events_cat');
        $name = $term->name;
        $title = $name;
    } elseif (is_tag()) {
        $name = 'Tag Archives';
        $title = $name;
    }
    echo '<h1>' . $title . '</h1>';
}
Beispiel #5
0
 /**
  * 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);
     }
 }
Beispiel #6
0
 /**
  *
  */
 function miss_document_title()
 {
     global $page, $paged, $wp_query;
     /* Set up some default variables. */
     $domain = MISS_TEXTDOMAIN;
     $doctitle = get_bloginfo('name');
     $separator = ' | ';
     $description = get_bloginfo('description', 'display');
     //$doctitle = get_bloginfo( 'name' );
     /* If viewing the front page and posts page of the site. */
     if (is_front_page() && is_home() && !is_singular()) {
         if ($description != "") {
             $doctitle = $description;
         } else {
             $separator = '';
         }
     }
     /* If viewing the posts page or a singular post. */
     if (is_home() || is_singular()) {
         $post_id = $wp_query->get_queried_object_id();
         $prefix = get_post_meta($post_id, 'Title', true);
         if (empty($prefix) && is_front_page()) {
             $prefix = get_bloginfo('name');
         } elseif (empty($prefix)) {
             $prefix = get_post_field('post_title', $post_id);
         }
     } elseif (is_archive()) {
         /* If viewing a taxonomy term archive. */
         if (is_category() || is_tag() || is_tax()) {
             $term = $wp_query->get_queried_object();
             $prefix = $term->name;
         } elseif (function_exists('is_post_type_archive') && is_post_type_archive()) {
             $post_type = get_post_type_object(get_query_var('post_type'));
             $prefix = miss_get_setting(get_post_type() . '_page_caption') ? miss_get_setting(get_post_type() . '_page_caption') : $post_type->labels->name;
         } elseif (is_author()) {
             $prefix = get_the_author_meta('display_name', get_query_var('author'));
         } elseif (is_date()) {
             if (get_query_var('minute') && get_query_var('hour')) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('g:i a', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('minute')) {
                 $prefix = sprintf(__('Archive for minute %1$s', MISS_TEXTDOMAIN), get_the_time(__('i', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('hour')) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('g a', MISS_TEXTDOMAIN)));
             } elseif (is_day()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('F jS, Y', MISS_TEXTDOMAIN)));
             } elseif (get_query_var('w')) {
                 $prefix = sprintf(__('Archive for week %1$s of %2$s', MISS_TEXTDOMAIN), get_the_time(__('W', MISS_TEXTDOMAIN)), get_the_time(__('Y', MISS_TEXTDOMAIN)));
             } elseif (is_month()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), single_month_title(' ', false));
             } elseif (is_year()) {
                 $prefix = sprintf(__('Archive for %1$s', MISS_TEXTDOMAIN), get_the_time(__('Y', MISS_TEXTDOMAIN)));
             }
         }
     } elseif (is_search()) {
         $prefix = sprintf(__('Search results for &quot;%1$s&quot;', MISS_TEXTDOMAIN), esc_attr(get_search_query()));
     } elseif (is_404()) {
         $prefix = __('404 Not Found', MISS_TEXTDOMAIN);
     } elseif (function_exists('bp_is_activity_component') && bp_is_activity_component()) {
         $prefix = __('Activity', MISS_TEXTDOMAIN);
     } elseif (function_exists('bp_is_group') && bp_is_group()) {
         $prefix = __('Group', MISS_TEXTDOMAIN);
     }
     /**
      * Events Calendar PRO Support
      * 
      * @since 1.8
      */
     if (class_exists('TribeEventsPro')) {
         if (function_exists('tribe_is_month') && tribe_is_month()) {
             $prefix = __('Events for', MISS_TEXTDOMAIN);
             $prefix .= Date("F Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_day') && tribe_is_day()) {
             $prefix = __('Events for', MISS_TEXTDOMAIN);
             $prefix .= Date("l, F jS Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_week') && tribe_is_week()) {
             if (function_exists('tribe_get_first_week_day')) {
                 $prefix = sprintf(__('Events for week of %s', MISS_TEXTDOMAIN), Date("l, F jS Y", strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
             }
             //$page_tagline = Date("l, F jS Y", strtotime($wp_query->get('start_date') ) );
         }
         if (function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo()) {
             if (tribe_is_past()) {
                 $prefix = __('Past Events', MISS_TEXTDOMAIN);
             } else {
                 $prefix = __('Upcoming Events', MISS_TEXTDOMAIN);
             }
         }
         if (function_exists('tribe_is_showing_all') && tribe_is_showing_all()) {
             $prefix = sprintf('%s %s', __('All events for', MISS_TEXTDOMAIN), get_the_title());
         }
     }
     /* If the current page is a paged page. */
     if ((($page = $wp_query->get('paged')) || ($page = $wp_query->get('page'))) && $page > 1) {
         $prefix = sprintf(__('%1$sPage %2$s', MISS_TEXTDOMAIN), $prefix . $separator, number_format_i18n($page));
     }
     if (is_front_page()) {
         $doctitle = $doctitle . $separator . $description;
     } else {
         $doctitle = $prefix . $separator . $doctitle;
     }
     /* Apply the wp_title filters so we're compatible with plugins. */
     $doctitle = apply_filters('wp_title', $doctitle, '', '');
     /* Return the title to the screen. */
     return apply_atomic('document_title', esc_attr($doctitle));
 }
 /**
  * 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.
  * @author Timothy Wood
  * @since 3.0
  */
 public function pre_get_posts($query)
 {
     $pro_query = false;
     $query->tribe_is_week = false;
     $query->tribe_is_day = false;
     $query->tribe_is_photo = false;
     $query->tribe_is_map = false;
     if (!empty($query->query_vars['eventDisplay'])) {
         $pro_query = true;
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('start_date', $week);
                 $query->set('eventDate', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 $query->tribe_is_week = true;
                 break;
             case 'day':
                 // a little hack to prevent 404 from happening on day view
                 add_filter('tribe_events_templates_is_404', '__return_false');
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d');
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('end_date', tribe_event_end_of_day($event_date));
                 $query->set('eventDate', $event_date);
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('posts_per_page', -1);
                 // show ALL day posts
                 $query->set('hide_upcoming', false);
                 $query->tribe_is_day = true;
                 break;
             case 'photo':
                 $tribe_event_display = !empty($_REQUEST['tribe_event_display']) ? $_REQUEST['tribe_event_display'] : '';
                 $tribe_paged = !empty($_REQUEST['tribe_paged']) ? $_REQUEST['tribe_paged'] : 0;
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d');
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('eventDate', $event_date);
                 $query->set('orderby', 'event_date');
                 $query->set('order', 'ASC');
                 $query->set('hide_upcoming', false);
                 $query->set('paged', $tribe_paged);
                 $query->tribe_is_photo = true;
                 if ($tribe_event_display === 'past') {
                     add_filter('tribe_events_pre_get_posts', array($this, 'set_past_events_query'), 20);
                 }
                 break;
             case 'map':
                 /*
                  * Query setup for the map view is located in
                  * TribeEventsGeoLoc->setup_geoloc_in_query()
                  */
                 $query->tribe_is_map = true;
         }
     }
     $query->tribe_is_event_pro_query = $pro_query;
     return $query->tribe_is_event_pro_query ? apply_filters('tribe_events_pro_pre_get_posts', $query) : $query;
 }
Beispiel #8
0
 /**
  * Get next week permalink by provided date (7 days offset)
  *
  * @uses tribe_get_week_permalink
  * @param string $week
  * @param bool $is_current
  * @return string $permalink
  * @since 3.0
  */
 function tribe_get_next_week_permalink($week = null)
 {
     $week = !empty($week) ? $week : tribe_get_first_week_day();
     $week = date('Y-m-d', strtotime($week . ' +1 week'));
     return apply_filters('tribe_get_next_week_permalink', tribe_get_week_permalink($week));
 }
Beispiel #9
0
 /**
  *
  */
 function miss_page_title()
 {
     global $irish_framework_params, $wp_query;
     if (is_front_page()) {
         return;
     }
     if (miss_is_template('templates/template-home.php')) {
         return;
     }
     $post_obj = $wp_query->get_queried_object();
     if (!empty($post_obj) && !empty($post_obj->ID) && get_post_meta($post_obj->ID, '_disable_page_title', true)) {
         return;
     }
     $title = '';
     if (is_404()) {
         $title = __('The requested page could not be found', MISS_TEXTDOMAIN);
         $page_tagline = __('Error 404', MISS_TEXTDOMAIN);
     }
     /**
      * Events Calendar PRO Support
      * 
      * @since 1.8
      */
     if (class_exists('TribeEventsPro')) {
         if (function_exists('tribe_is_month') && tribe_is_month()) {
             $title = __('Events for', MISS_TEXTDOMAIN);
             $page_tagline = Date("F Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_day') && tribe_is_day()) {
             $title = __('Events for', MISS_TEXTDOMAIN);
             $page_tagline = Date("l, F jS Y", strtotime($wp_query->get('start_date')));
         }
         if (function_exists('tribe_is_week') && tribe_is_week()) {
             if (function_exists('tribe_get_first_week_day')) {
                 $title = sprintf(__('Events for week of %s', MISS_TEXTDOMAIN), Date("l, F jS Y", strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
             }
             $page_tagline = '';
         }
         if (function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo()) {
             if (tribe_is_past()) {
                 $title = __('Past Events', MISS_TEXTDOMAIN);
             } else {
                 $title = __('Upcoming Events', MISS_TEXTDOMAIN);
             }
             $page_tagline = '';
         }
         if (function_exists('tribe_is_showing_all') && tribe_is_showing_all()) {
             $title = sprintf('%s %s', __('All events for', MISS_TEXTDOMAIN), get_the_title());
             $page_tagline = '';
         }
     }
     $intro_options = miss_get_setting('intro_options');
     if (is_search()) {
         $title = sprintf(__('Search Results for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . get_search_query() . '&rsquo;');
     } elseif (is_category()) {
         $title = sprintf(__('Category Archive for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . single_cat_title('', false) . '&rsquo;');
     } elseif (is_archive() || is_singular('post')) {
         $title = sprintf(__('%1$s', MISS_TEXTDOMAIN), miss_get_setting(get_post_type() . '_page_caption') ? miss_get_setting(get_post_type() . '_page_caption') : get_post_type());
     } elseif (is_tag()) {
         $title = sprintf(__('All Posts Tagged Tag: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . single_tag_title('', false) . '&rsquo;');
     } elseif (is_day()) {
         $title = sprintf(__('Daily Archive for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . get_the_time('F jS, Y') . '&rsquo;');
     } elseif (is_month()) {
         $title = sprintf(__('Monthly Archive for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . get_the_time('F, Y') . '&rsquo;');
     } elseif (is_year()) {
         $title = sprintf(__('Yearly Archive for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . get_the_time('Y') . '&rsquo;');
     } elseif (is_singular('portfolio')) {
         $gallery_id = miss_get_setting('portfolio_page');
         if (!empty($gallery_id)) {
             $title = get_the_title($gallery_id);
         }
     } elseif (function_exists('is_woocommerce') && is_woocommerce()) {
         $shop_page = get_post(woocommerce_get_page_id('shop'));
         $title = miss_get_setting('store_title') ? get_option('store_title') : (get_option('woocommerce_shop_page_title') ? get_option('woocommerce_shop_page_title') : __('Store', MISS_TEXTDOMAIN));
         $page_tagline = miss_get_setting('product_page_tagline') ? get_option('product_page_tagline') : '';
     } elseif (is_author()) {
         global $author;
         $curauth = get_userdata(intval($author));
         $title = sprintf(__('Author Archive for: %1$s', MISS_TEXTDOMAIN), '&lsquo;' . $curauth->nickname . '&rsquo;');
         if (is_search()) {
             $title = printf(__('Search Results: &ldquo;%s&rdquo;', MISS_TEXTDOMAIN), get_search_query());
         } elseif (is_tax()) {
             $title = single_term_title("", false);
         } else {
             $shop_page = get_post(woocommerce_get_page_id('shop'));
             $title = miss_get_setting('store_title') ? get_option('store_title') : (get_option('woocommerce_shop_page_title') ? get_option('woocommerce_shop_page_title') : __('Store', MISS_TEXTDOMAIN));
             $page_tagline = miss_get_setting('product_page_tagline') ? get_option('product_page_tagline') : '';
         }
     }
     if (!empty($title)) {
         if (!empty($page_tagline)) {
             $page_tagline = '<span class="page_tagline">' . $page_tagline . '</span>';
             $title .= $page_tagline;
         }
         return '<h1 class="page_title">' . $title . '</h1>';
     } else {
         global $wp_query;
         $post_obj = $wp_query->get_queried_object();
         $post_id = is_object($post_obj) && isset($post_obj->ID) ? $post_obj->ID : '';
         $page_title = get_the_title($post_id);
         if (empty($page_title)) {
             return false;
         }
         $_layout = get_post_meta($post_id, '_intro_text', true);
         $template = get_post_meta($post_id, '_wp_page_template', true);
         if (!isset($page_tagline)) {
             $page_tagline = get_post_meta($post_id, '_page_tagline', true);
         }
         if (!empty($page_tagline)) {
             $page_tagline = '<span class="page_tagline">' . $page_tagline . '</span>';
         } else {
             $page_tagline = '';
         }
         if (is_page()) {
             if (is_front_page() != 1 || $template != 'templates/template-home.php') {
                 return the_title('<h1 class="page_title">', $page_tagline . '</h1>', false);
             } elseif ($_layout == 'default' && $intro_options == 'disable' && $template != 'templates/template-wiki.php') {
                 return the_title('<h1 class="page_title">', $page_tagline . '</h1>', false);
             }
         } else {
             return '<h1 class="page_title">' . get_the_title($post_id) . $page_tagline . '</h1>';
         }
     }
 }
Beispiel #10
0
 /**
  * Build the next week link
  *
  * @param string $text the text to be linked
  *
  * @return string
  */
 function tribe_events_week_next_link($text = '')
 {
     try {
         $date = date(Tribe__Events__Date_Utils::DBDATEFORMAT, strtotime(tribe_get_first_week_day() . ' +1 week'));
         if ($date >= tribe_events_latest_date(Tribe__Events__Date_Utils::DBDATEFORMAT)) {
             return '';
         }
         $url = tribe_get_next_week_permalink();
         if (empty($text)) {
             $text = __('Next Week <span>&raquo;</span>', 'tribe-events-calendar-pro');
         }
         global $wp_query;
         $current_week = tribe_get_first_week_day($wp_query->get('start_date'));
         $attributes = sprintf(' data-week="%s" ', date('Y-m-d', strtotime($current_week . ' +7 days')));
         return sprintf('<a %s href="%s" rel="next">%s</a>', $attributes, esc_url($url), $text);
     } catch (OverflowException $e) {
         return '';
     }
 }
Beispiel #11
0
 function tribe_next_week_link($text = '')
 {
     try {
         $date = date(TribeDateUtils::DBDATEFORMAT, strtotime(tribe_get_first_week_day() . ' +1 week'));
         if ($date >= tribe_events_latest_date(TribeDateUtils::DBDATEFORMAT)) {
             return '';
         }
         $url = tribe_get_next_week_permalink();
         if (empty($text)) {
             $text = __('Next Week <span>&raquo;</span>', 'tribe-events-calendar-pro');
         }
         return sprintf('<a %s href="%s" rel="next">%s</a>', tribe_events_the_nav_attributes('next', false), $url, $text);
     } catch (OverflowException $e) {
         return '';
     }
 }
 /**
  * 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.
  * @author Timothy Wood
  * @since 3.0
  */
 public function pre_get_posts($query)
 {
     if (!empty($query->tribe_is_event_pro_query)) {
         switch ($query->query_vars['eventDisplay']) {
             case 'week':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('eventDate', $week);
                 $query->set('start_date', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $query->set('posts_per_page', -1);
                 // show ALL week posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'day':
                 $event_date = $query->get('eventDate') != '' ? $query->get('eventDate') : Date('Y-m-d', current_time('timestamp'));
                 $query->set('eventDate', $event_date);
                 $query->set('start_date', tribe_event_beginning_of_day($event_date));
                 $query->set('end_date', tribe_event_end_of_day($event_date));
                 $query->set('posts_per_page', -1);
                 // show ALL day posts
                 $query->set('hide_upcoming', false);
                 break;
             case 'photo':
                 $query->set('hide_upcoming', false);
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }
 /**
  * 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.
  * @author Timothy Wood
  * @since 3.0
  */
 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':
                 $week = tribe_get_first_week_day($query->get('eventDate'));
                 $query->set('eventDate', $week);
                 $query->set('start_date', $week);
                 $query->set('end_date', tribe_get_last_week_day($week));
                 $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']);
                 $all_ids = TribeEventsRecurrenceMeta::get_events_by_slug($slug);
                 if (empty($all_ids)) {
                     $query->set('p', -1);
                 } else {
                     $query->set('post__in', $all_ids);
                     $query->set('post_status', 'publish');
                 }
                 break;
         }
         apply_filters('tribe_events_pro_pre_get_posts', $query);
     }
 }
Beispiel #14
0
 /**
  * Get next week permalink by provided date (7 days offset)
  *
  * @uses tribe_get_week_permalink
  *
  * @param string $week
  *
  * @return string $permalink
  * @todo move logic to week template class
  */
 function tribe_get_next_week_permalink($week = null)
 {
     $week = !empty($week) ? $week : tribe_get_first_week_day();
     if (PHP_INT_SIZE <= 4) {
         if (date('Y-m-d', strtotime($week)) > '2037-12-24') {
             throw new OverflowException(__('Date out of range.', 'tribe-events-calendar-pro'));
         }
     }
     $week = date('Y-m-d', strtotime($week . ' +1 week'));
     return apply_filters('tribe_get_next_week_permalink', tribe_get_week_permalink($week));
 }
Beispiel #15
0
 function fitclub_tribe_alter_event_archive_titles($depth)
 {
     // Modify the titles here
     // Some of these include %1$s and %2$s, these will be replaced with relevant dates
     $title_upcoming = esc_html__('Upcoming Events', 'fitclub');
     // List View: Upcoming events
     $title_past = esc_html__('Past Events', 'fitclub');
     // List view: Past events
     $title_range = esc_html__('Events for %1$s - %2$s', 'fitclub');
     // List view: range of dates being viewed
     $title_month = esc_html__('Events for %1$s', 'fitclub');
     // Month View, %1$s = the name of the month
     $title_day = esc_html__('Events for %1$s', 'fitclub');
     // Day View, %1$s = the day
     $title_all = esc_html__('All events for %s', 'fitclub');
     // showing all recurrences of an event, %s = event title
     $title_week = esc_html__('Events for week of %s', 'fitclub');
     // Week view
     // Don't modify anything below this unless you know what it does
     global $wp_query;
     $tribe_ecp = Tribe__Events__Main::instance();
     $date_format = apply_filters('tribe_events_pro_page_title_date_format', tribe_get_date_format(true));
     // Default Title
     $title = $title_upcoming;
     // If there's a date selected in the tribe bar, show the date range of the currently showing events
     if (isset($_REQUEST['tribe-bar-date']) && $wp_query->have_posts()) {
         if ($wp_query->get('paged') > 1) {
             // if we're on page 1, show the selected tribe-bar-date as the first date in the range
             $first_event_date = tribe_get_start_date($wp_query->posts[0], false);
         } else {
             //otherwise show the start date of the first event in the results
             $first_event_date = tribe_format_date($_REQUEST['tribe-bar-date'], false);
         }
         $last_event_date = tribe_get_end_date($wp_query->posts[count($wp_query->posts) - 1], false);
         $title = sprintf($title_range, $first_event_date, $last_event_date);
     } elseif (tribe_is_past()) {
         $title = $title_past;
     }
     // Month view title
     if (tribe_is_month()) {
         $title = sprintf($title_month, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date())));
     }
     // Single view title
     if (tribe_is_event() && is_single()) {
         $title = get_the_title();
     }
     // Day view title
     if (tribe_is_day()) {
         $title = sprintf($title_day, date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date'))));
     }
     // All recurrences of an event
     if (function_exists('tribe_is_showing_all') && tribe_is_showing_all()) {
         $title = sprintf($title_all, get_the_title());
     }
     // Week view title
     if (function_exists('tribe_is_week') && tribe_is_week()) {
         $title = sprintf($title_week, date_i18n($date_format, strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
     }
     if (is_tax($tribe_ecp->get_event_taxonomy()) && $depth) {
         $cat = get_queried_object();
         $title = $cat->name;
     }
     return $title;
 }
Beispiel #16
0
/**
 * Breadcrumbs Functions
 *
 * @since 1.0
 * @param array $args
 * @return string
 */
function miss_get_breadcrumbs($args = '')
{
    global $wp_query;
    $breadcrumb_delimiter = miss_get_setting('breadcrumb_delimiter');
    $delimiter = !empty($breadcrumb_delimiter) ? html_entity_decode(htmlentities($breadcrumb_delimiter)) : '&raquo';
    /* Set up the default arguments for the breadcrumb. */
    $defaults = array('prefix' => '', 'suffix' => '', 'title' => '', 'home' => __('Home', MISS_TEXTDOMAIN), 'sep' => $delimiter, 'front_page' => false, 'bold' => true, 'show_blog' => true, 'singular_post_taxonomy' => null, 'echo' => false);
    $args = apply_filters('miss_breadcrumbs_args', $args);
    $args = wp_parse_args($args, $defaults);
    if (is_front_page() && !$args['front_page']) {
        return apply_filters('miss_get_breadcrumbs', false);
    }
    /* Format the title. */
    $html = !empty($args['title']) ? '<span class="breadcrumbs-title">' . $args['title'] . '</span>' : '';
    /* Format the separator. */
    $separator = !empty($args['sep']) ? ' <span class="delimiter">' . $args['sep'] . '</span> ' : ' <span class="delimiter">/</span> ';
    $show_on_front = get_option('show_on_front');
    $home = '<a href="' . home_url('/') . '" rel="home" class="home_breadcrumb">' . $args['home'] . '</a>';
    if ('page' == $show_on_front && $args['show_blog']) {
        $bloglink = $home . $separator . '<a href="' . get_permalink(get_option('page_for_posts')) . '">' . get_the_title(get_option('page_for_posts')) . '</a>';
    } else {
        $bloglink = $home;
    }
    if (is_front_page()) {
        $html .= miss_breadcrumbs_bold($home, $args['bold']);
    } elseif (is_home()) {
        $html .= $home . $separator . miss_breadcrumbs_bold(get_the_title(get_option('page_for_posts')), $args['bold']);
    } elseif (function_exists('is_woocommerce') && is_woocommerce()) {
        $html .= $home . $separator . __("Store", MISS_TEXTDOMAIN);
        /* If viewing a portfolio post. */
    } elseif (is_singular('portfolio')) {
        $html .= $home . $separator;
        $gallery_id = miss_get_setting('portfolio_page');
        if (!empty($gallery_id)) {
            $html .= '<a href="' . get_permalink($gallery_id) . '" title="' . esc_attr(get_the_title($gallery_id)) . '">' . get_the_title($gallery_id) . '</a>' . $separator;
        }
        $html .= miss_breadcrumbs_bold(get_the_title(), $args['bold']);
        /* Added to refect miss_blog_page() */
        /* If viewing a singular post. */
    } elseif (is_singular('miss_gallery')) {
        $html .= $home . $separator;
        $gallery_id = miss_get_setting('gallery_page');
        if (!empty($gallery_id)) {
            $html .= '<a href="' . get_permalink($gallery_id) . '" title="' . esc_attr(get_the_title($gallery_id)) . '">' . get_the_title($gallery_id) . '</a>' . $separator;
        }
        $html .= miss_breadcrumbs_bold(get_the_title(), $args['bold']);
    } elseif (is_singular('news')) {
        $html .= $home . $separator;
        $gallery_id = miss_get_setting('news_page');
        if (!empty($gallery_id)) {
            $html .= '<a href="' . get_permalink($gallery_id) . '" title="' . esc_attr(get_the_title($gallery_id)) . '">' . get_the_title($gallery_id) . '</a>' . $separator;
        }
        $html .= miss_breadcrumbs_bold(get_the_title(), $args['bold']);
    } elseif (is_archive() && get_post_type() == 'news') {
        $html .= $home . $separator . __('News', MISS_TEXTDOMAIN);
    } elseif (get_post_type() == 'forum' || get_post_type() == 'topic' || get_post_type() == 'reply') {
        $html .= bbp_get_breadcrumb(array('before' => '', 'after' => '', 'sep' => $separator));
    } elseif (is_singular('benefits')) {
        $html .= $home . $separator;
        $gallery_id = miss_get_setting('benefits_page');
        if (!empty($gallery_id)) {
            $html .= '<a href="' . get_permalink($gallery_id) . '" title="' . esc_attr(get_the_title($gallery_id)) . '">' . get_the_title($gallery_id) . '</a>' . $separator;
        }
        $html .= miss_breadcrumbs_bold(get_the_title(), $args['bold']);
    } elseif (is_singular()) {
        $post_id = (int) $wp_query->get_queried_object_id();
        if (isset($wp_query) && isset($wp_query->post) && is_object($wp_query->post)) {
            if ('page' === $wp_query->post->post_type || 'pricetable' === $wp_query->post->post_type) {
                $html .= $home . $separator;
            } elseif ('page' !== $wp_query->post->post_type) {
                $html .= $bloglink . $separator;
                if (isset($args["singular_{$wp_query->post->post_type}_taxonomy"]) && is_taxonomy_hierarchical($args["singular_{$wp_query->post->post_type}_taxonomy"])) {
                    $terms = wp_get_object_terms($post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"]);
                    $html .= miss_breadcrumbs_get_term_parents($terms[0], $args["singular_{$wp_query->post->post_type}_taxonomy"], $separator) . $separator;
                } elseif (isset($args["singular_{$wp_query->post->post_type}_taxonomy"])) {
                    $html .= get_the_term_list($post_id, $args["singular_{$wp_query->post->post_type}_taxonomy"], '', ', ', '') . $separator;
                }
            }
            if ((is_post_type_hierarchical($wp_query->post->post_type) || 'attachment' === $wp_query->post->post_type) && ($parents = miss_breadcrumbs_get_parents($wp_query->post->post_parent, $separator))) {
                $html .= $parents . $separator;
            }
        } else {
            if (miss_is_bp()) {
                $html .= $home . $separator;
            }
        }
        $html .= miss_breadcrumbs_bold(get_the_title(), $args['bold']);
    } elseif (is_archive()) {
        $html .= $bloglink . $separator;
        if (is_category() || is_tag() || is_tax()) {
            $term = $wp_query->get_queried_object();
            $taxonomy = get_taxonomy($term->taxonomy);
            if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent && ($parents = miss_breadcrumbs_get_term_parents($term->parent, $term->taxonomy, $separator))) {
                $html .= $parents . $separator;
            }
            $html .= miss_breadcrumbs_bold($term->name, $args['bold']);
        } elseif (get_post_type() == 'news') {
            $html .= miss_breadcrumbs_bold(__('News', MISS_TEXTDOMAIN));
        } elseif (function_exists('is_post_type_archive') && is_post_type_archive()) {
            $post_type_object = get_post_type_object(get_query_var('post_type'));
            $html .= miss_breadcrumbs_bold($post_type_object->labels->name, $args['bold']);
        } elseif (is_date()) {
            if (is_day()) {
                $html .= miss_breadcrumbs_bold(__('Archives for ', MISS_TEXTDOMAIN) . get_the_time('F j, Y'), $args['bold']);
            } elseif (is_month()) {
                $html .= miss_breadcrumbs_bold(__('Archives for ', MISS_TEXTDOMAIN) . single_month_title(' ', false), $args['bold']);
            } elseif (is_year()) {
                $html .= miss_breadcrumbs_bold(__('Archives for ', MISS_TEXTDOMAIN) . get_the_time('Y'), $args['bold']);
            }
        } elseif (is_author()) {
            $html .= miss_breadcrumbs_bold(__('Archives by: ', MISS_TEXTDOMAIN) . get_the_author_meta('display_name', $wp_query->post->post_author), $args['bold']);
        }
    } elseif (miss_is_bp()) {
        global $bp;
        // we're outside the loop!
        //print_r( $bp );
        if (isset($bp) && is_object($bp) && isset($bp->current_component)) {
            // Assign some variables here
            $homeurl = get_bloginfo('url');
            $bp_page1 = $bp->members->root_slug;
            // bp_get_members_root_slug() // slug for the Members page. The BuddyPress default is 'members'.
            $bp_page2 = $bp->groups->root_slug;
            // bp_get_groups_root_slug() // slug for the Groups page. The BuddyPress default is 'groups'.
            $bp_page3 = $bp->activity->root_slug;
            // bp_get_activity_root_slug() // slug for the Activity page. The BuddyPress default is 'activity'.
            $bp_page4 = $bp->forums->root_slug;
            // bp_get_forums_root_slug() // slug for the Forums page. The BuddyPress default is 'forums'.
            //$bp_page5 = $bp->achievements->root_slug; // slug for the Achievements page. The BuddyPress default is 'achievements'.
            if (bp_is_group()) {
                $html .= $home . $separator . __('Groups', MISS_TEXTDOMAIN);
                if (is_404()) {
                    $html .= $separator . miss_breadcrumbs_bold(__('Not Found', MISS_TEXTDOMAIN), $args['bold']);
                }
            }
            if (bp_is_user() && !bp_is_register_page()) {
                $html .= $home . " {$separator} " . '<a href="' . $homeurl . '/' . $bp_page1 . '/">' . ucwords($bp_page1) . '</a>' . " {$separator} " . '<a href="' . $bp->displayed_user->domain . '">' . ucwords($bp->displayed_user->fullname) . '</a>' . " {$divider} " . ucwords($bp->current_component) . "";
            }
            if (!bp_is_blog_page() && (is_page() || is_page($bp_page1) || is_page($bp_page2) || is_page($bp_page3) || is_page($bp_page4)) && !bp_is_user() && !bp_is_single_item() && !bp_is_register_page()) {
                $html .= $home . " {$separator} " . get_the_title() . "";
            }
            if (bp_is_register_page()) {
                $html .= $home . " {$separator} " . get_the_title() . "";
            }
            if (bp_is_blog_page() && is_home() && $front == "page") {
                $html .= "<a href='" . $homeurl . "'>{$home}</a>" . " {$separator} " . $blog . "";
            }
            if (get_query_var('paged')) {
                if (bp_is_blog_page() && !(is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())) {
                    $html .= ' (Page' . ' ' . get_query_var('paged') . ')';
                }
            }
            /* 		$html .= $home . $separator . miss_breadcrumbs_bold( __( 'Search results for "', MISS_TEXTDOMAIN ) . stripslashes( strip_tags( get_search_query() ) ) . '"', $args['bold'] ); */
        }
    } elseif (is_search()) {
        $html .= $home . $separator . miss_breadcrumbs_bold(__('Search results for "', MISS_TEXTDOMAIN) . stripslashes(strip_tags(get_search_query())) . '"', $args['bold']);
    } elseif (is_404()) {
        $html .= $home . $separator . miss_breadcrumbs_bold(__('Page Not Found', MISS_TEXTDOMAIN), $args['bold']);
    } else {
        $html = '';
    }
    if (class_exists('TribeEventsPro')) {
        if (class_exists('TribeEvents')) {
            $tec = TribeEvents::instance();
            $events_page = '<a href="' . home_url('/') . trailingslashit($tec->getOption('eventsSlug', 'events')) . '" title="' . __('Events', MISS_TEXTDOMAIN) . '">' . __('Events', MISS_TEXTDOMAIN) . '</a>';
            $html_event = $home . $separator . $events_page;
        }
        if (function_exists('tribe_is_month') && tribe_is_month()) {
            $html = $html_event;
            $html .= $separator . __('Events for', MISS_TEXTDOMAIN) . ' ' . Date("F Y", strtotime($wp_query->get('start_date')));
        }
        if (function_exists('tribe_is_day') && tribe_is_day()) {
            $html = $html_event;
            $html .= $separator . __('Events for', MISS_TEXTDOMAIN) . ' ' . Date("l, F jS Y", strtotime($wp_query->get('start_date')));
        }
        if (function_exists('tribe_is_week') && tribe_is_week()) {
            if (function_exists('tribe_get_first_week_day')) {
                $html = $html_event;
                $html .= $separator . sprintf(__('Events for week of %s', MISS_TEXTDOMAIN), Date("l, F jS Y", strtotime(tribe_get_first_week_day($wp_query->get('start_date')))));
            }
        }
        if (function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo()) {
            if (tribe_is_past()) {
                $html = $html_event;
                $html .= $separator . __('Past Events', MISS_TEXTDOMAIN);
            } else {
                $html = $html_event;
                $html .= $separator . __('Upcoming Events', MISS_TEXTDOMAIN);
            }
        }
        if (function_exists('tribe_is_showing_all') && tribe_is_showing_all()) {
            $html = $html_event;
            $html .= $separator . sprintf('%s %s', __('All events for', MISS_TEXTDOMAIN), get_the_title());
        }
    }
    //$breadcrumbs = '<div class="breadcrumb breadcrumbs"><div class="breadcrumbs-plus">';
    $breadcrumbs = $args['prefix'];
    $breadcrumbs .= $html;
    $breadcrumbs .= $args['suffix'];
    //$breadcrumbs .= '</div></div>';
    $breadcrumbs = apply_filters('miss_get_breadcrumbs', $breadcrumbs);
    if (!$args['echo']) {
        return $breadcrumbs;
    }
    echo $breadcrumbs;
}
Beispiel #17
0
 /**
  * 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);
     }
 }