功能介绍

PC与手机显示有差异,在电脑端能正常显示的功能,转到手机上可能只有文字,而且排版还乱糟糟的。加入此代码,可直接取消在手机端显示。

配置教程

一、打开主题或者子主题根目录,找到functions.php文件,将下面代码放在最后

/* 是否手机端访问*/
function is_mobile() {
	$user_agent = $_SERVER['HTTP_USER_AGENT'];
	$mobile_browser = Array(
		"mqqbrowser", //手机QQ浏览器
		"opera mobi", //手机opera
		"juc","iuc",//uc浏览器
		"fennec","ios","applewebKit/420","applewebkit/525","applewebkit/532","ipad","iphone","ipaq","ipod",
		"iemobile", "windows ce",//windows phone
		"240x320","480x640","acer","android","anywhereyougo.com","asus","audio","blackberry","blazer","coolpad" ,"dopod", "etouch", "hitachi","htc","huawei", "jbrowser", "lenovo","lg","lg-","lge-","lge", "mobi","moto","nokia","phone","samsung","sony","symbian","tablet","tianyu","wap","xda","xde","zte"
	);
	$is_mobile = false;
	foreach ($mobile_browser as $device) {
		if (stristr($user_agent, $device)) {
			$is_mobile = true;
			break;
		}
	}
	return $is_mobile;
}

二、在你想取消的功能外部加一个 if 语句

前边:
<?php if (is_mobile()==false): ?>

后边:
<?php endif; ?>

例如:

<?php if (is_mobile()==false): ?>

<!--功能区域------底部波浪-->
<?php if (_lan('bluefanqie_lan_footer_wave') ) : ?>
<div class="waveHorizontals mobile-hide">
  <div id="waveHorizontal1" class="waveHorizontal"></div>
  <div id="waveHorizontal2" class="waveHorizontal"></div>
  <div id="waveHorizontal3" class="waveHorizontal"></div>
</div>

<?php endif; ?>

 

判断是否手机端登录网站-WordPress主题小技巧插图

1、本站资源均存储在云盘,如发现链接失效,请联系我们我们会第一时间更新;
    2、根据2013年1月30日《计算机软件保护条例》2次修订第17条规定:
             为了学习和研究软件内含的设计思想和原理,通过安装、显示、传输或者存储软件等方式使用软件的,
             可以不经软件著作权人许可,不向其支付报酬!鉴于此,也希望大家按此说明研究软件!
    3、本站资源仅供学习和研究,大家请在下载后24小时内删除, 请勿进行商业交易、运营等行为;
    4、本站所有源码都来源于网络收集修改或者交换!如果侵犯了您的权益,请及时告知我们,我们即刻处理!