Created
June 29, 2015 14:16
-
-
Save barryhughes/fcf8231ce9bd8d07ca38 to your computer and use it in GitHub Desktop.
Temp fix - tribe_is_week() detection during ajax requests
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
/** | |
* A bug prevents tribe_is_week() from working reliably during ajax loads of | |
* week view - this presents a few problems including the Show First Recurring | |
* Instance setting being applied incorrectly to that view. | |
* | |
* This provides a temporary fix until it can be addressed in a future update | |
* of Events Calendar PRO. | |
* | |
* @see <http://theeventscalendar.com/support/forums/topic/week-view-requires-reloadrefresh-to-show-all-recurring-events/> | |
* @param bool $status | |
* @return bool | |
*/ | |
function fix_37301_ajax_tribe_is_week( $status ) { | |
// Don't interfere if it is not a frontend ajax request | |
$front_ajax = is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX; | |
if ( ! $front_ajax ) return $status; | |
// We can't rely on the $wp_query global here (at least not in | |
// 3.10) so let's fall back on the $_REQUEST superglobal instead | |
return ( 'tribe_week' === @$_REQUEST['action'] ); | |
} | |
add_filter( 'tribe_is_week', 'fix_37301_ajax_tribe_is_week' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment