Forked from barryhughes/temp-fix-embedded-month-view-day-links.php
Last active
May 2, 2019 16:04
-
-
Save jentheo/6a813c75463864a901bf40d30ae7cfa4 to your computer and use it in GitHub Desktop.
Provides a temp workaround to help ensure the more event/view all X event links within month view are functional
This file contains hidden or 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 | |
/** | |
* Ensure that month view 'view all X events' on this day links are functional. | |
* | |
* This is a temporary workaround for a bug in Events Calendar PRO 4.4.20.1. | |
*/ | |
add_filter( 'tribe_get_day_link', function( $url, $date ) { | |
// Intervention is only needed following navigation by ajax | |
if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { | |
return $url; | |
} | |
// Sanity check: only intervene if we have a valid date to work with | |
if ( ! preg_match( '/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $date ) ) { | |
return $url; | |
} | |
// Ensure the expected view parameters are in place | |
$view_params = [ | |
'tribe-bar-date' => $date, | |
'tribe_event_display' => 'day' | |
]; | |
$url = remove_query_arg( 'date', $url ); | |
return add_query_arg( $view_params, $url ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment