Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @asafm7

    Currently, there is no functionality in the AMP plugin that can force AMP on desktop users while using transition mode.

    I would like to know if there any particular reason why you want to force AMP on desktop users with transitional mode? why not switch to Standard Mode instead?

    Thread Starter asafm7

    (@asafm7)

    Thanks for your reply.

    The reason is that even on Standard Mode I might need to disable AMP for a specific page. There is a simple toggle for it, and it’s great.

    The thing is Google Site Kit’s integration with the AMP plugin doesn’t support a regular (non-AMP) Google Tag Manager container. So, if I have a non-AMP page on a Standard Mode setup – I can’t track it with Google Site Kit.

    I hope it is clear enough.

    Please see here:
    https://github.com/google/site-kit-wp/issues/2998

    Plugin Support Milind More

    (@milindmore22)

    Hello @asafm7

    Ok understood, I will recommend using server-side redirection using amp_mobile_client_side_redirection filter along with amp_is_available
    example:

    add_action(
    	'wp',
    	function() {
    		add_action( 'amp_mobile_client_side_redirection', '__return_false' );
    		add_filter( 'amp_pre_is_mobile', '__return_true' );
    
    		if ( ! isset( $_GET['noamp'] ) && function_exists( 'is_amp_endpoint' ) && ! is_amp_endpoint() && function_exists( 'amp_is_available' ) && amp_is_available() ) {
    			wp_safe_redirect( esc_url( add_query_arg( 'amp', '1', get_permalink() ) ), 302 );
    		}
    	}
    );

    OR

    you can also utilize the mobile redirection script provided by AMP plugin by sending desktop user agents with amp_mobile_user_agents filter.

    example:

    add_filter(
    	'amp_mobile_user_agents',
    	function( $user_agents ) {
    		$user_agents[] = 'Macintosh';
    		$user_agents[] = 'Windows';
    		$user_agents[] = 'Win64';
    		$user_agents[] = 'Linux';
    		// Add more user agents here.
    		// @url https://developers.whatismybrowser.com/useragents/explore/software_type_specific/web-browser/2
    		return $user_agents;
    	}
    );

    hope this helps

    Plugin Support Milind More

    (@milindmore22)

    Hello @asafm7

    I hope the solution helped you, As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Forcing AMP on desktop on Transitional mode’ is closed to new replies.