Skip to content

更新判断UA的代码 #6

Description

@xuejianxianzun

/func/wp-useragent-detect.php 里面使用了 wp-useragent 插件的代码来判断访客浏览器和操作系统,但是几年前还没有 edge ,所以现在识别不出来 edge 了。

当然,这个主题应该是不会进行更新了,如果其他人也遇到了这个问题的话,可以看下解决办法。

目前我从 wp-useragent 新版本里借用过来了这部分代码,建议添加到 clrs_detect_webbrowser 函数判断部分的最前面。

if (preg_match('/Edge/i', $useragent)
		&& preg_match('/Chrome/i', $useragent)
		&& preg_match('/Safari/i', $useragent))
	{
		$link = 'http://en.wikipedia.org/wiki/Microsoft_Edge';
		$title = 'Microsoft Edge';
		$code = 'msedge12';
	}

然后下载 WP-UserAgent 的最新版本,把 img/16/net/msedge12.png 图片复制到主题对应文件夹里就可以了。

WP-UserAgent 插件地址:https://wordpress.org/plugins/wp-useragent/

这个主题已经是四年前的了,时至今日 WP-UserAgent 里的改动应该不止这一个地方,如果各位在这方面遇到了更多的问题,可以考虑删除 function.php 里的clrs_wp_useragent();,安装这个插件来代替。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions