/** * Output data attributes needed to update the month with ajax * * @return void **/ function tribe_events_the_mini_calendar_header_attributes() { $args = tribe_events_get_mini_calendar_args(); if (is_array($args['tax_query'])) { $args['tax_query'] = json_encode($args['tax_query']); } $html = ''; $html .= ' data-count="' . esc_attr($args['count']) . '"'; $html .= ' data-eventDate="' . esc_attr(tribe_get_month_view_date()) . '"'; $html .= ' data-tax-query="' . esc_attr($args['tax_query']) . '"'; $html .= ' data-nonce="' . wp_create_nonce('calendar-ajax') . '"'; echo apply_filters('tribe_events_the_mini_calendar_header_attributes', $html); }
function wpv_upcoming_events_title($title) { $upcoming = wpv_get_option('tribe-events-upcoming-title'); $past = wpv_get_option('tribe-events-past-title'); $month = wpv_get_option('tribe-events-month-title'); if (!empty($upcoming) && (tribe_is_upcoming() || function_exists('tribe_is_map') && tribe_is_map() || function_exists('tribe_is_photo') && tribe_is_photo())) { return $upcoming; } elseif (!empty($past) && tribe_is_past()) { return $past; } elseif (!empty($month) && tribe_is_month()) { return sprintf($month, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } return $title; }
<?php /* Template Name: Custom Homepage Template */ get_header(); $date = tribe_get_month_view_date(); ?> <h1 class="page-title visually-hidden">Welcome to Seniors Outdoors!</h1> <div class="page-content"> <section class="featured"> <?php $found = false; $wp_query = new WP_Query('post_type=tribe_events'); if ($wp_query->have_posts()) { while ($wp_query->have_posts()) { $wp_query->the_post(); if (has_term('featured-event', 'tribe_events_cat') and !$found) { $other_info = get_field('other_info'); $venue = tribe_get_venue(); $found = true; ?> <h2 class="event-title purple-dark"><?php the_title(); ?> </h2> <p class="single-space"><?php
/** * Next Month Text * * Returns a textual description of the next month * * @return string Name of the next month. */ function tribe_get_next_month_text() { $tribe_ecp = Tribe__Events__Main::instance(); try { $output = $tribe_ecp->getDateStringShortened($tribe_ecp->nextMonth(tribe_get_month_view_date())); } catch (OverflowException $e) { $output = ''; } return apply_filters('tribe_get_next_month_text', $output); }
/** * Event Title * * Return an event's title with pseudo-breadcrumb if on a category * * @param bool $depth include linked title * @return string title */ function tribe_get_events_title($depth = true) { global $wp_query; $tribe_ecp = TribeEvents::instance(); $title = __('Upcoming Events', 'tribe-events-calendar'); // TODO: Use the displayed dates for the title if (tribe_is_past()) { $title = __('Past Events', 'tribe-events-calendar'); } if (tribe_is_month()) { $title = sprintf(__('Events for %s', 'tribe-events-calendar'), date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } // day view title if (tribe_is_day()) { $title = __('Events for', 'tribe-events-calendar') . ' ' . date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date'))); } if (is_tax($tribe_ecp->get_event_taxonomy())) { $cat = get_queried_object(); if ($depth) { $title = '<a href="' . tribe_get_events_link() . '">' . $title . '</a>'; $title .= ' › ' . $cat->name; } else { $title = $cat->name; } } return apply_filters('tribe_template_factory_debug', apply_filters('tribe_get_events_title', $title), 'tribe_get_events_title'); }
/** * Gets all events in the current month, matching those presented in month view * by default (and therefore potentially including some events from the tail end * of the previous month and start of the following month). * * We build a fresh 'custom'-type query here rather than taking advantage of the * main query since page spoofing can render the actual query and results * inaccessible (and it cannot be recovered via a query reset). * * @return array events in the month */ private static function get_month_view_events() { global $wp_query; $event_date = $wp_query->get('eventDate'); $month = empty($event_date) ? tribe_get_month_view_date() : $wp_query->get('eventDate'); $args = array('eventDisplay' => 'custom', 'start_date' => Tribe__Events__Template__Month::calculate_first_cell_date($month), 'end_date' => Tribe__Events__Template__Month::calculate_final_cell_date($month), 'posts_per_page' => -1, 'hide_upcoming' => true); /** * Provides an opportunity to modify the query args used to build a list of events * to export from month view. * * This could be useful where its desirable to limit the exported data set to only * those events taking place in the specific month being viewed (rather than an exact * match of the events shown in month view itself, which may include events from * adjacent months). * * @var array $args * @var string $month */ $args = (array) apply_filters('tribe_ical_feed_month_view_query_args', $args, $month); return tribe_get_events($args); }
/** * Prints out data attributes used in the template header tags * * @category Events * @param string|null $current_view * * @return void * @todo move to template classes **/ function tribe_events_the_header_attributes($current_view = null) { $attrs = array(); $current_view = !empty($current_view) ? $current_view : basename(tribe_get_current_template()); $attrs['data-title'] = wp_title('|', false, 'right'); switch ($current_view) { case 'month.php': $attrs['data-view'] = 'month'; $attrs['data-date'] = date('Y-m', strtotime(tribe_get_month_view_date())); $attrs['data-baseurl'] = tribe_get_gridview_link(false); break; case 'day.php': $attrs['data-startofweek'] = get_option('start_of_week'); break; case 'list.php': $attrs['data-startofweek'] = get_option('start_of_week'); $attrs['data-view'] = 'list'; if (tribe_is_upcoming()) { $attrs['data-baseurl'] = tribe_get_listview_link(false); } elseif (tribe_is_past()) { $attrs['data-view'] = 'past'; $attrs['data-baseurl'] = tribe_get_listview_past_link(false); } break; } if (has_filter('tribe_events_mobile_breakpoint')) { $attrs['data-mobilebreak'] = tribe_get_mobile_breakpoint(); } $attrs = apply_filters('tribe_events_header_attributes', $attrs, $current_view); foreach ($attrs as $attr => $value) { echo " {$attr}=" . '"' . esc_attr($value) . '"'; } }
/** * Prints out data attributes used in the template header tags * * @param string|null $current_view * @return void * @since 3.0 **/ function tribe_events_the_header_attributes($current_view = null) { $attrs = array(); $current_view = !empty($current_view) ? $current_view : basename(tribe_get_current_template()); $attrs['data-title'] = wp_title('»', false); switch ($current_view) { case 'month.php': $attrs['data-view'] = 'month'; $attrs['data-date'] = date('Y-m', strtotime(tribe_get_month_view_date())); $attrs['data-baseurl'] = tribe_get_gridview_link(false); break; case 'list.php': $attrs['data-view'] = 'list'; if (tribe_is_upcoming()) { $attrs['data-baseurl'] = tribe_get_listview_link(false); } elseif (tribe_is_past()) { $attrs['data-view'] = 'past'; $attrs['data-baseurl'] = tribe_get_listview_past_link(false); } break; } $attrs = apply_filters('tribe_events_header_attributes', $attrs, $current_view); foreach ($attrs as $attr => $value) { echo " {$attr}=" . '"' . $value . '"'; } }
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; }
function axiom_tribe_events_get_period_links($links, $page, $delimiter = '') { if (!empty($links)) { return $links; } global $post; if ($page == 'tribe_day' && is_object($post)) { $links = '<a class="breadcrumbs_item cat_parent" href="' . tribe_get_gridview_link(false) . '">' . date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date())) . '</a>'; } return $links; }
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>'; }
function getBlogTitle() { global $wp_query; $page = getBlogType(); if (themerex_strpos($page, 'woocommerce') !== false) { if ($page == 'woocommerce_category') { $cat = get_term_by('slug', get_query_var('product_cat'), 'product_cat', ARRAY_A); return $cat['name']; } else { if ($page == 'woocommerce_tag') { return sprintf(__('Tag: %s', 'themerex'), single_tag_title('', false)); } else { if ($page == 'woocommerce_cart') { return __('Your cart', 'themerex'); } else { if ($page == 'woocommerce_checkout') { return __('Checkout', 'themerex'); } else { if ($page == 'woocommerce_account') { return __('Account', 'themerex'); } else { if ($page == 'woocommerce_product') { return getPostTitle(); } else { if (($page_id = get_option('woocommerce_shop_page_id')) > 0) { return getPostTitle($page_id); } //__( 'Shop', 'themerex' ); } } } } } } } else { if (themerex_strpos($page, 'tribe') !== false) { //return tribe_get_events_title(); if ($page == 'tribe_category') { $cat = get_term_by('slug', get_query_var('tribe_events_cat'), 'tribe_events_cat', ARRAY_A); return $cat['name']; } else { if ($page == 'tribe_tag') { return sprintf(__('Tag: %s', 'themerex'), single_tag_title('', false)); } else { if ($page == 'tribe_venue') { return sprintf(__('Venue: %s', 'themerex'), tribe_get_venue()); } else { if ($page == 'tribe_organizer') { return sprintf(__('Organizer: %s', 'themerex'), tribe_get_organizer()); } else { if ($page == 'tribe_day') { return sprintf(__('Daily Events: %s', 'themerex'), date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date')))); } else { if ($page == 'tribe_month') { return sprintf(__('Monthly Events: %s', 'themerex'), date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } else { if ($page == 'tribe_event') { return getPostTitle(); } else { return __('Tribe Events', 'themerex'); } } } } } } } } else { if ($page == 'blog') { return __('All Posts', 'themerex'); } else { if ($page == 'author') { $curauth = get_query_var('author_name') ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); return sprintf(__('Author page: %s', 'themerex'), $curauth->display_name); } else { if ($page == 'error') { return __('URL not found', 'themerex'); } else { if ($page == 'search') { return sprintf(__('Search Results for: %s', 'themerex'), get_search_query()); } else { if ($page == 'archives_day') { return sprintf(__('Daily Archives: %s', 'themerex'), prepareDateForTranslation(get_the_date())); } else { if ($page == 'archives_month') { return sprintf(__('Monthly Archives: %s', 'themerex'), prepareDateForTranslation(get_the_date('F Y'))); } else { if ($page == 'archives_year') { return sprintf(__('Yearly Archives: %s', 'themerex'), get_the_date('Y')); } else { if ($page == 'category') { return sprintf(__('%s', 'themerex'), single_cat_title('', false)); } else { if ($page == 'tag') { return sprintf(__('Tag: %s', 'themerex'), single_tag_title('', false)); } else { if ($page == 'attachment') { return sprintf(__('Attachment: %s', 'themerex'), getPostTitle()); } else { if ($page == 'single') { return getPostTitle(); } else { if ($page == 'page') { return getPostTitle(); } else { return get_bloginfo('name', 'raw'); } } } } } } } } } } } } } } // Unknown pages - as homepage }
?> </a></h3> </li> <?php } // End of the loop. ?> </ul> </div> <div class="top-news-wrapp"> <h2><a href="<?php echo get_home_url() . '/events'; ?> ">Навігатор подій</a></h2> <?php $title = sprintf(__('%1$s %2$s', 'tribe-events-calendar'), $events_label_plural, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); ?> <h5 class="today"><?php echo $title; ?> </h5> <?php tribe_show_month(); ?> <?php ?> </div> <!-- <div class="event-calendar">--> <!-- --><?php //tribe_show_month(); ?>
/** * Next Month Text * * Returns a textual description of the next month * * @return string Name of the next month. * @since 2.0 */ function tribe_get_next_month_text() { $tribe_ecp = TribeEvents::instance(); $output = $tribe_ecp->getDateStringShortened($tribe_ecp->nextMonth(tribe_get_month_view_date())); return apply_filters('tribe_get_next_month_text', $output); }
/** * Event Title * * Return an event's title with pseudo-breadcrumb if on a category * * @param bool $depth include linked title * @return string title * @since 2.0 */ function tribe_get_events_title($depth = true) { global $wp_query; $tribe_ecp = TribeEvents::instance(); $title = __('Upcoming Events', 'tribe-events-calendar'); // TODO: Use the displayed dates for the title /* if ( tribe_is_upcoming() || isset( $_REQUEST['tribe-bar-date'] ) ) { $start_date = date( 'Y-m-d', strtotime( $wp_query->get( 'start_date' ) ) ); if ( $wp_query->get( 'start_date' ) && $start_date != date('Y-m-d') ) { if ( get_query_var('paged') > 1 ) { // get the date of the first post $first_post = reset($wp_query->posts); $start_date = date('Y-m-d', strtotime($first_post->EventStartDate)); } $format = __('Events for %1$s', 'tribe-events-calendar'); $args = array(date_i18n( get_option( 'date_format', 'Y-m-d' ), strtotime($start_date) )); // Get the date of the last post if ( count($wp_query->posts) > 1 ) { $last_post = end($wp_query->posts); $last_post_date = date('Y-m-d', strtotime($last_post->EventStartDate)); if ( $last_post_date != $start_date ) { $format = __('Events for %1$s through %2$s', 'tribe-events-calendar'); $args[] = date_i18n( get_option( 'date_format', 'Y-m-d' ), strtotime($last_post_date) ); } } $title = vsprintf($format, $args); } } else */ if (tribe_is_past()) { $title = __('Past Events', 'tribe-events-calendar'); } if (tribe_is_month()) { $title = sprintf(__('Events for %s', 'tribe-events-calendar'), date_i18n(__('F Y', 'tribe-events-calendar'), strtotime(tribe_get_month_view_date()))); } if (is_tax($tribe_ecp->get_event_taxonomy())) { $cat = get_queried_object(); if ($depth) { $title = '<a href="' . tribe_get_events_link() . '">' . $title . '</a>'; $title .= ' › ' . $cat->name; } else { $title = $cat->name; } } return apply_filters('tribe_template_factory_debug', apply_filters('tribe_get_events_title', $title), 'tribe_get_events_title'); }
/** * @deprecated */ function sp_get_month_view_date() { _deprecated_function(__FUNCTION__, '2.0', 'tribe_get_month_view_date()'); return tribe_get_month_view_date(); }
/** * Next Month Text * * Returns a textual description of the next month * * @return string Name of the next month. * @since 2.0 */ function tribe_get_next_month_text() { $tribe_ecp = TribeEvents::instance(); return $tribe_ecp->getDateString($tribe_ecp->nextMonth(tribe_get_month_view_date())); }
/** * Event Title * * Return an event's title with pseudo-breadcrumb if on a category * * @param bool $depth include linked title * * @return string title * @todo move logic to template classes */ function tribe_get_events_title($depth = true) { $events_label_plural = tribe_get_event_label_plural(); global $wp_query; $tribe_ecp = Tribe__Events__Main::instance(); $title = sprintf(__('Upcoming %s', 'tribe-events-calendar'), $events_label_plural); // 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_event_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(__('%1$s for %2$s - %3$s', 'tribe-events-calendar'), $events_label_plural, $first_event_date, $last_event_date); } elseif (tribe_is_past()) { $title = sprintf(__('Past %s', 'tribe-events-calendar'), $events_label_plural); } if (tribe_is_month()) { $title = sprintf(__('%1$s for %2$s', 'tribe-events-calendar'), $events_label_plural, date_i18n(tribe_get_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } // day view title if (tribe_is_day()) { $title = sprintf(__('%1$s for %2$s', 'tribe-events-calendar'), $events_label_plural, date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date')))); } if (is_tax($tribe_ecp->get_event_taxonomy()) && $depth) { $cat = get_queried_object(); $title = '<a href="' . esc_url(tribe_get_events_link()) . '">' . $title . '</a>'; $title .= ' › ' . $cat->name; } return apply_filters('tribe_get_events_title', $title, $depth); }
/** * Sets up an array of $days based on the current query, that can be used in the calendar loop * * @return void **/ public function setup_view() { $requested_date = isset(self::$args['eventDate']) ? self::$args['eventDate'] : tribe_get_month_view_date(); $first_day_of_month = date('Y-m-01', strtotime($requested_date)); $first_grid_date = $this->calculate_first_cell_date($requested_date); $final_grid_date = $this->calculate_final_cell_date($requested_date); $days = array(); $this->setup_tribe_bar_args(); $this->current_day_vals(); do_action('log', 'setup view month view args', 'tribe-month', self::$args); do_action('log', 'eventDate', 'tribe-events-query', $first_day_of_month); self::$hide_upcoming_ids = TribeEventsQuery::getHideFromUpcomingEvents(); self::get_daily_counts($first_grid_date, $final_grid_date); $date = $first_grid_date; // Start with the first grid date $empty = new WP_Query(); // Use for empty days // Populate complete date range including leading/trailing days from adjacent months while ($date <= $final_grid_date) { $day = (int) substr($date, -2); $total_events = !empty(self::$event_daily_counts[$date]) ? self::$event_daily_counts[$date] : 0; $prev_month = (int) substr($date, 5, 2) < (int) substr($requested_date, 5, 2); $next_month = (int) substr($date, 5, 2) > (int) substr($requested_date, 5, 2); $month_type = self::CURRENT_MONTH; if ($prev_month) { $month_type = self::PREVIOUS_MONTH; } if ($next_month) { $month_type = self::NEXT_MONTH; } $days[] = array('daynum' => $day, 'date' => $date, 'events' => $total_events ? self::get_daily_events($date) : $empty, 'total_events' => $total_events, 'view_more' => self::view_more_link($date, self::$tribe_bar_args), 'month' => $month_type); // Record the indicies marking the portion of the array relating to the current month if (!isset($this->current_month_begins) && self::CURRENT_MONTH === $month_type) { $this->current_month_begins = count($days) - 1; } if (isset($this->current_month_begins) && !isset($this->current_month_ends) && self::CURRENT_MONTH !== $month_type) { $this->current_month_ends = count($days) - 1; } // Advance forward one day $date = date(TribeDateUtils::DBDATEFORMAT, strtotime("{$date} +1 day")); } // If the month ended without bleeding into the next month, our current_month_ends property may not be set if (!isset($this->current_month_ends)) { $this->current_month_ends = count($days) - 1; } // store set of found days for use in calendar loop functions self::$calendar_days = $days; }
/** * Sets up an array of $days based on the current query, that can be used in the calendar loop * * @return void **/ public function setup_view() { do_action('log', 'setup view month view args', 'tribe-month', self::$args); $requested_date = isset(self::$args['eventDate']) ? self::$args['eventDate'] : tribe_get_month_view_date(); $first_day_of_month = date('Y-m-01', strtotime($requested_date)); do_action('log', 'eventDate', 'tribe-events-query', $first_day_of_month); // get all upcoming ids to hide so we're not querying 31 times self::$hide_upcoming_ids = TribeEventsQuery::getHideFromUpcomingEvents(); $year = date('Y', strtotime($first_day_of_month)); $month = date('m', strtotime($first_day_of_month)); $startOfWeek = get_option('start_of_week', 0); self::get_daily_counts($first_day_of_month); if (empty(self::$tribe_bar_args)) { foreach ($_REQUEST as $key => $value) { if ($value && strpos($key, 'tribe') === 0 && $key != 'tribe-bar-date') { self::$tribe_bar_args[$key] = $value; } } } // Var'ng up days, months and years self::$today = date_i18n('d'); self::$current_month = date_i18n('m'); self::$current_year = date_i18n('Y'); // single dimensional array of days for the month $days = array(); // setup counters $rawOffset = date('w', strtotime($first_day_of_month)) - $startOfWeek; $prev_month_offset = (int) ($rawOffset < 0 ? $rawOffset + 7 : $rawOffset); // month begins on day x $days_in_month = (int) date('t', strtotime($first_day_of_month)); $days_in_calendar = $days_in_month + $prev_month_offset; while ($days_in_calendar % 7 > 0) { $days_in_calendar++; } $cur_calendar_day = 0; // fill month with required days for previous month if ($prev_month_offset > 0) { $days = array_fill(0, $prev_month_offset, array('date' => 'previous')); } // get $cur_calendar_day up to speed $cur_calendar_day += $prev_month_offset; $empty_query = new WP_Query(); // add days for this month for ($i = 0; $i < $days_in_month; $i++) { $day = $i + 1; $date = date('Y-m-d', strtotime("{$year}-{$month}-{$day}")); $total_events = !empty(self::$event_daily_counts[$date]) ? self::$event_daily_counts[$date] : 0; $days[] = array('daynum' => $day, 'date' => $date, 'events' => $total_events ? self::get_daily_events($date) : $empty_query, 'total_events' => $total_events, 'view_more' => self::view_more_link($date, self::$tribe_bar_args)); } // get $cur_calendar_day up to speed $cur_calendar_day += $days_in_month; // check if $cur_calendar_day is less than $days_in_calendar, if so, add days for next month if ($cur_calendar_day < $days_in_calendar) { $days = array_merge($days, array_fill($cur_calendar_day, $days_in_calendar - $cur_calendar_day, array('date' => 'next'))); } // store set of found days for use in calendar loop functions self::$calendar_days = $days; }
* top, the same way it is here. * * When you create your page, you can just select the template and viola, you have * a custom page template to call your very own. Your mother would be so proud. * * For more info: http://codex.wordpress.org/Page_Templates */ ?> <?php get_header(); ?> <div id="content"> <div id="inner-content" class="wrap cf"> <main id="main" class="m-all t-2of3 d-5of7 cf" role="main" itemscope itemprop="mainContentOfPage" itemtype="http://schema.org/Blog"> <?php echo tribe_get_month_view_date ( ); ?> </main> <?php get_sidebar(); ?> </div> </div> <?php get_footer(); ?>
/** * Returns the requested date as a Y-m (yyyy-mm) formatted string. * * If the requested date is invalid (such as 1984-25) the current month is returned instead and * an appropriate notice presented to the user. * * @return string */ protected function requested_date() { // We expect the date to be Y-m (yyyy-mm) format, ie year and date only $date = isset($this->args['eventDate']) ? $this->args['eventDate'] : tribe_get_month_view_date(); // Test and return unmodified if valid if (false !== strtotime($date . '-01')) { return $date; } else { Tribe__Notices::set_notice('requested-date-invalid', sprintf(esc_html__('The requested date "%s" was not valid – showing the current month instead', 'the-events-calendar'), esc_html($date))); return date_i18n('Y-m'); } }
/** * Event Title * * Return an event's title with pseudo-breadcrumb if on a category * * @param bool $depth include linked title * * @return string title * @todo move logic to template classes */ function tribe_get_events_title($depth = true) { $events_label_plural = tribe_get_event_label_plural(); global $wp_query; $tribe_ecp = Tribe__Events__Main::instance(); $title = sprintf(esc_html__('Upcoming %s', 'the-events-calendar'), $events_label_plural); // 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()) { $first_returned_date = tribe_get_start_date($wp_query->posts[0], false, Tribe__Date_Utils::DBDATEFORMAT); $first_event_date = tribe_get_start_date($wp_query->posts[0], false); $last_event_date = tribe_get_end_date($wp_query->posts[count($wp_query->posts) - 1], false); // If we are on page 1 then we may wish to use the *selected* start date in place of the // first returned event date if (1 == $wp_query->get('paged') && $_REQUEST['tribe-bar-date'] < $first_returned_date) { $first_event_date = tribe_format_date($_REQUEST['tribe-bar-date'], false); } $title = sprintf(__('%1$s for %2$s - %3$s', 'the-events-calendar'), $events_label_plural, $first_event_date, $last_event_date); } elseif (tribe_is_past()) { $title = sprintf(esc_html__('Past %s', 'the-events-calendar'), $events_label_plural); } if (tribe_is_month()) { $title = sprintf(esc_html__('%1$s for %2$s', 'the-events-calendar'), $events_label_plural, date_i18n(tribe_get_date_option('monthAndYearFormat', 'F Y'), strtotime(tribe_get_month_view_date()))); } // day view title if (tribe_is_day()) { $title = sprintf(esc_html__('%1$s for %2$s', 'the-events-calendar'), $events_label_plural, date_i18n(tribe_get_date_format(true), strtotime($wp_query->get('start_date')))); } if (is_tax($tribe_ecp->get_event_taxonomy()) && $depth) { $cat = get_queried_object(); $title = '<a href="' . esc_url(tribe_get_events_link()) . '">' . $title . '</a>'; $title .= ' › ' . $cat->name; } return apply_filters('tribe_get_events_title', $title, $depth); }