Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Last active February 9, 2017 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseeproductions/63c72d77ecc1959b20ec01d0912bfa0f to your computer and use it in GitHub Desktop.
Save jesseeproductions/63c72d77ecc1959b20ec01d0912bfa0f to your computer and use it in GitHub Desktop.
The Events Calendar List View Multi Day Events Show Today as the Start Date
<?php
/*
Plugin Name: A Snippet for List View Multi Day Events Start Time - The Events Calendar
Plugin URI: http://theeventscalendar.com
Description: This plugin changes the List View Start Times for Multiple Day Events.
Author: brianjessee
Version: 1.0
Author URI: http://theeventscalendar.com
*/
/**
* Example if an Event runs from May 1st to June 31st when visiting the list view on June 10th
* it looks like the first event is in May, but it is currently June. This snippet changes it
* so it displays JUne 10th as the start date in the list view.
*/
if ( ! function_exists( 'tribe_get_start_date' ) ) {
/**
* Start Date
*
* Returns the event start date and time
*
* @category Events
*
* @param int $event (optional)
* @param bool $display_time If true shows date and time, if false only shows date
* @param string $date_format Allows date and time formating using standard php syntax (http://php.net/manual/en/function.date.php)
* @param string $timezone Timezone in which to present the date/time (or default behaviour if not set)
*
* @return string|null Date
*/
function tribe_get_start_date( $event = null, $display_time = true, $date_format = '', $timezone = null ) {
if ( is_null( $event ) ) {
global $post;
$event = $post;
}
if ( is_numeric( $event ) ) {
$event = get_post( $event );
}
if ( ! is_object( $event ) ) {
return '';
}
if ( Tribe__Date_Utils::is_all_day( get_post_meta( $event->ID, '_EventAllDay', true ) ) ) {
$display_time = false;
}
// @todo move timezones to Common
if ( class_exists( 'Tribe__Events__Timezones' ) ) {
$start_date = Tribe__Events__Timezones::event_start_timestamp( $event->ID, $timezone );
} else {
return null;
}
if ( tribe_is_list_view() && ! tribe_is_past() ) {
//echo $start_date . ' start <br>';
$blogtime = current_time( 'mysql' );
//echo strtotime( $cc_blogtime ) . ' mysql <br>';
if ( $start_date > $blogtime ) {
//echo $start_date . 'less <br>';
$start_date = $blogtime;
//echo $start_date . 'new <br>';
}
}
return tribe_format_date( $start_date, $display_time, $date_format );
}
}
@andrasguseo
Copy link

This tweaked version might be helpful as well:
https://gist.github.com/andrasguseo/d252c9e0c85c96e5a2bcfe36b0d09031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment