最新消息:20210917 已从crifan.com换到crifan.org

【已解决】wordpress的插件WPtouch不支持Nokia的Symbian系统

WordPress crifan 2844浏览 0评论

【问题】

之前看了WPtouch中文语言包WordPress Mobile Themes中关于WPtouch的介绍,所以去其WPTouch的主页看了简介后,去网站后台插件管理中安装了此插件,当前版本是1.9.41。

但是安装后,用自己的Nokia的E5-00去通过wiki访问网站,结果还是显示的是桌面版的主题。

没有出现期望的WPTouch的移动版的主题。

【解决过程】

1.想要通过手机的CMNET或CMWAP去访问网站,结果两者都有问题,所以暂时放弃尝试。

2.参考:让WPtouch支持Nokia,去找对应的config.php,结果没有找到。

然后又去编辑WPTouch插件的源码,然后无意间在其主文件wptouch.php中找到了detectAppleMobile,然后没有找到其所说的wptouch_device_classes,

3.后来倒是找到了detectAppleMobile函数,然后看到了userAgent是通过bnc_wptouch_get_user_agents获得的。

然后就去找bnc_wptouch_get_user_agents,然后找到了,对应定义:

function bnc_wptouch_get_user_agents() {
	$useragents = array(		
		"iPhone",  				 	// Apple iPhone
		"iPod", 						// Apple iPod touch
		"incognito", 				// Other iPhone browser
		"webmate", 				// Other iPhone browser
		"Android", 			 	// 1.5+ Android
		"dream", 				 	// Pre 1.5 Android
		"CUPCAKE", 			 	// 1.5+ Android
		"blackberry9500",	 	// Storm
		"blackberry9530",	 	// Storm
		"blackberry9520",	 	// Storm v2
		"blackberry9550",	 	// Storm v2
		"blackberry 9800",	// Torch
		"webOS",					// Palm Pre Experimental
		"s8000", 				 	// Samsung Dolphin browser
		"bada",				 		// Samsung Dolphin browser
		"Googlebot-Mobile"	// the Google mobile crawler

	);

 

然后就去添加nokia的symbian支持了:

试了,结果还是不行。

4.尝试去添加调试信息,即把:

	function detectAppleMobile($query = '') {
		$container = $_SERVER['HTTP_USER_AGENT'];
		// The below prints out the user agent array. Uncomment to see it shown on the page.
		// print_r($container); 

 

中的print_r打开,变成了:

	function detectAppleMobile($query = '') {
		$container = $_SERVER['HTTP_USER_AGENT'];
		// The below prints out the user agent array. Uncomment to see it shown on the page.
		print_r($container); 

然后果然可以看到对应输出了。

通过360浏览器浏览自己网站,显示的是:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; 360SE)Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; 360SE) 

Nokia E5-00上面浏览自己的网站,显示的是:

NOKIAE5-00/UCWEB8.5.0.163/28/999NOKIAE5-00/UCWEB8.5.0.163/28/999

而且也看到了detectAppleMobile中是通过正则表达式去查找匹配关键字的:

	function detectAppleMobile($query = '') {
		$container = $_SERVER['HTTP_USER_AGENT'];
		// The below prints out the user agent array. Uncomment to see it shown on the page.
		print_r($container); 
		$this->applemobile = false;
		$useragents = bnc_wptouch_get_user_agents();
		$exclude_agents = bnc_wptouch_get_exclude_user_agents();
		$devfile =  compat_get_plugin_dir( 'wptouch' ) . '/include/developer.mode';

		foreach ( $useragents as $useragent ) {
			if ( preg_match( "#$useragent#i", $container ) || file_exists( $devfile ) ) {
				$this->applemobile = true;
				break;
			}
		}

所以又去添加对应的NOKIA的支持:

function bnc_wptouch_get_user_agents() {
	$useragents = array(
		"symbian",	// Nokia symbian
		"NOKIA",	//Nokia device		
		"iPhone",  				 	// Apple iPhone

结果在点击更新文件的时候,网页变成只显示那个输出的useragent了。

然后重新进去后台管理页面,发现此wptouch被禁用了。

感觉好像是改了代码,弄得有问题,wordpress自动给禁用了。

5.然后去重新启动此插件,结果系统提示:

这个插件在启用的过程中产生了 70 个字符的异常输出。如果您遇到了“headers already sent”错误、联合 feed(如 RSS)出错等问题,请尝试禁用或移除本插件。

真是悲催。

不过后来发现,上述的输出:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; 360SE)Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; 360SE)

其实是两个重复的输入,而单个的输出,正好是70个字符,所以,上述提示,也就是指的是这部分的输出。

其是我添加的debug的输出,所以是没问题的。

关键的一点是,重新启用后,用Nokia 的E5-00访问www.crifan.org后,发现的确主题变了,是那种calender的效果了。哈哈。

所以,再回去,把那个print_r重新注释掉,不让其输出,即可。

最后放一张WPtouch在Nokia E5-00,通过UC浏览器浏览的效果:

WPTouch效果截图

【总结】

WPTouch(至少当前的1.9.41版本)默认不支持Nokia的Symbian系统,导致用Nokia的手机浏览网站,没有显示出对应的Mobile Theme的效果。

方法是,将对应的NOKIA等字样,添加到对应的useragent支持列表中,即可。

转载请注明:在路上 » 【已解决】wordpress的插件WPtouch不支持Nokia的Symbian系统

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (5)

  1. 呵呵 兄弟说的有道理,不知道你用的哪个版本的。貌似后台可以直接添加哦
    lhsy8811年前 (2013-08-20)回复
  2. 您有没注意过,手机上的谷广告不显示呀,只是一段空白。您去查看下好吗?www.qq681.com.等待回复,谢谢!
    zp11年前 (2012-12-30)回复
    • “谷广告”啥意思?
      crifan11年前 (2012-12-30)回复
      • 就是插件里面有个广告服务,我看了下。仅支持谷哥联盟广告,我输入了Google AdSense ID和广告代码,在手机上只有段空白,没有显示出广告内容。而在计算机上的网页版显示正常!
        zp11年前 (2013-01-02)回复
        • 通过计算机查看网页,没看到你的网站上有谷歌广告。
          crifan11年前 (2013-01-05)回复
102 queries in 0.184 seconds, using 23.39MB memory