【问题】
之前看了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(至少当前的1.9.41版本)默认不支持Nokia的Symbian系统,导致用Nokia的手机浏览网站,没有显示出对应的Mobile Theme的效果。
方法是,将对应的NOKIA等字样,添加到对应的useragent支持列表中,即可。
