I used wordpress for a site and any theme switcher, wich gives me a link to switch betwen different themes of the web, Also used a code to redirect to a “mobile friendly” home page created specific for mobile users.
If a mobile user clicks on switch to desktop version a link to switch back to mobile version should apper. I used wp_get_referer(); and according to this code. should work but nothing happens. 🙁
add_action( 'storefront_footer', 'boton_movil', 20 );
function boton_movil(){
$referer = wp_get_referer();
$sitio = get_site_url();
$mobil = $sitio.'/mobile';
if ($referer == $mobil ) {
?>
<div class="footer_mobil">
<a href="<?php get_site_url(); ?>/mobile/?am_force_theme_layout=mobile"><i class="fa fa-desktop"></i></a>
<div class="texto_menu_mobil">
Go back to mobile version
</div>
</div>
<?php
}
}
Of course if a users comes directly to a desktop version, the link should not appear
You can use the function get_browser of php
get_browser
it retunrs a array with ismobiledevice key or you can use a api like wurfl