amp_mobile_client_side_redirection

apply_filters( 'amp_mobile_client_side_redirection',  bool $should_redirect_via_js )

Description #

Filters whether mobile redirection should be done client-side (via JavaScript).

If false, a server-side solution will be used instead (via PHP). It's important to verify that server-side redirection does not conflict with a site's page caching logic. To assist with this, you may need to hook into the amp_pre_is_mobile filter.
Beware that disabling this will result in a cookie being set when the user decides to leave the mobile version. This may require updating the site's privacy policy or getting user consent for GDPR compliance. Nevertheless, since the cookie is not used for tracking this may not be necessary.
Please note that this does not apply when in the Customizer preview or when in AMP Dev Mode (and thus possible Paired Browsing), since server-side redirects would not be able to be prevented as required.


Parameters #

$should_redirect_via_js

(bool) Whether JS redirection should be used to take mobile visitors to the AMP version.



Changelog #

Changelog
Version Description
2.0 Introduced.