Created
January 5, 2016 19:23
-
-
Save barryhughes/4d9b7c73594e8f6c9838 to your computer and use it in GitHub Desktop.
Possible temp workaround for an issue where week view 'jumps' to the next upcoming week in conditions where it still ought to show the current week (due to timezone issues)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function temp_fix_42765( $date ) { | |
global $wp_query; | |
if ( ! empty( $wp_query->get( 'eventDate' ) ) ) | |
return $date; | |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) | |
return $date; | |
try { | |
$week_start = new DateTime( current_time( 'Y-m-d' ) ); | |
$offset = 7 - get_option( 'start_of_week', 0 ); | |
$week_start->modify( - ( ( $week_start->format( 'w' ) + $offset ) % 7 ) . 'days' ); | |
} | |
catch ( Exception $e ) { | |
return $date; | |
} | |
return $week_start->format( 'Y-m-d' ); | |
} | |
add_filter( 'tribe_get_first_week_day', 'temp_fix_42765' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment