简体   繁体   English

仅向来自移动网站的用户显示桌面版本上的切换到移动链接

[英]Show switch to mobile link on desktop version only to users who come from mobile site

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. 我使用wordpress来访问网站和任何主题切换器,它为我提供了一个链接,可以切换不同的Web主题,还使用代码重定向到专门为移动用户创建的“移动友好”主页。

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(); 我用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 您可以使用php的get_browser函数

get_browser get_browser

it retunrs a array with ismobiledevice key or you can use a api like wurfl 它使用ismobiledevice重新调谐数组,或者您可以使用wurfl之类的API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM