Tribe__Tickets__Tickets_View::prevent_page_redirect( WP_Query $query )
By default WordPress has a nasty if query_var[‘p’] is a page then redirect to the page, so we will change the variables accordingly.
Contents
Parameters
- $query
-
(WP_Query) (Required) The current Query.
Return
(void)
Source
File: src/Tribe/Tickets_View.php
public function prevent_page_redirect( $query ) {
$is_correct_page = isset( $query->query_vars['tribe-edit-orders'] ) && $query->query_vars['tribe-edit-orders'];
if ( ! $is_correct_page ) {
return;
}
// This has no Performance problems, since get_post uses caching and we use this method later on.
$post = isset( $query->query_vars['p'] ) ? get_post( absint( $query->query_vars['p'] ) ) : 0;
if ( ! $post ) {
return;
}
if ( ! tribe_tickets_post_type_enabled( $post->post_type ) ) {
return;
}
$query->query_vars['post_type'] = $post->post_type;
if ( 'page' === $post->post_type ) {
// Unset the p variable, we dont need it anymore
unset( $query->query_vars['p'] );
// Set `page_id` for faster query
$query->query_vars['page_id'] = $post->ID;
}
}