Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created June 29, 2015 14:16
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 barryhughes/fcf8231ce9bd8d07ca38 to your computer and use it in GitHub Desktop.
Save barryhughes/fcf8231ce9bd8d07ca38 to your computer and use it in GitHub Desktop.
Temp fix - tribe_is_week() detection during ajax requests
/**
* 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