Template_Bootstrap::on_template_redirect()
Redirects the user to the default mobile view if required.
When on mobile (in terms of device capacity) we redirect to the default mobile View. To avoid caching issues, where the cache provider would need to keep a mobile and non-mobile version of the cached pages, we redirect with explicit View slug.
See also
Source
File: src/Tribe/Views/V2/Template_Bootstrap.php
public function on_template_redirect() {
if (
! wp_is_mobile()
|| tribe_is_truthy( tribe_get_request_var( 'tribe_redirected' ) )
|| is_singular()
|| is_tax()
) {
return;
}
$default_view = $this->manager->get_default_view_option( 'desktop' );
$default_mobile_view = $this->manager->get_default_view_option( 'mobile' );
if ( $default_view === $default_mobile_view ) {
return;
}
$ugly_url = add_query_arg(
[
'post_type' => TEC::POSTTYPE,
'eventDisplay' => $default_mobile_view,
'tribe_redirected' => true,
],
home_url()
);
$location = Rewrite::instance()->get_canonical_url( $ugly_url );
wp_redirect(
$location,
302
);
tribe_exit();
}
Changelog
| Version | Description |
|---|---|
| 4.9.11 | Introduced. |