Skip to content

Commit

Permalink
Merge pull request #418 from mirai-mamori/preview
Browse files Browse the repository at this point in the history
クリスマスソング Special Update
  • Loading branch information
mirai-mamori authored Dec 24, 2021
2 parents 90ece29 + 0f2fd0e commit 64d8921
Show file tree
Hide file tree
Showing 23 changed files with 675 additions and 335 deletions.
3 changes: 1 addition & 2 deletions inc/swicher.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ function font_end_js_control() {
$mashiro_opt['code_highlight_prism']['theme'] = ['dark' => $theme_dark];
}
}
wp_add_inline_script('app', 'const mashiro_option = '.json_encode($mashiro_opt,JSON_NUMERIC_CHECK|JSON_UNESCAPED_UNICODE),'before');
wp_add_inline_script('app', 'const mashiro_global = {}', 'before');
wp_add_inline_script('app', 'var mashiro_option = '.json_encode($mashiro_opt,JSON_NUMERIC_CHECK|JSON_UNESCAPED_UNICODE),'before');
}
add_action('wp_head', 'font_end_js_control');
200 changes: 67 additions & 133 deletions inc/theme_plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,182 +721,116 @@ function disable_dashboard_widgets() {
* 获取用户UA信息
*/
// 浏览器信息
function siren_get_browsers($ua){
$title = 'unknow';
$icon = 'unknow';
if (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Internet Explorer '. $matches[1];
if ( strpos($matches[1], '7') !== false || strpos($matches[1], '8') !== false)
$icon = 'ie8';
elseif ( strpos($matches[1], '9') !== false)
$icon = 'ie9';
elseif ( strpos($matches[1], '10') !== false)
$icon = 'ie10';
else
$icon = 'ie';
}elseif (preg_match('#Edge/([a-zA-Z0-9.]+)#i', $ua, $matches)){
$title = 'Edge '. $matches[1];
$icon = 'edge';
}elseif (preg_match('#Edg/([a-zA-Z0-9.]+)#i', $ua, $matches)){
$title = 'Edge (Chromium) '. $matches[1];
$icon = 'edge';
}elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = '360 Browser '. $matches[1];
$icon = '360se';
}elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'SouGou Browser 2'.$matches[1];
$icon = 'sogou';
}elseif (preg_match('#LBBROWSER#i', $ua, $matches)) {
$title = 'CM Browser';
$icon = 'LBBROWSER';
}elseif (preg_match('#MicroMessenger/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Built-in Browser of WeChat '.$matches[1];
$icon = 'wechat';
}elseif (preg_match('#QQBrowser/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'QQBrowser '.$matches[1];
$icon = 'QQBrowser';
}elseif (preg_match('#BIDUBrowser/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Baidu Browser '.$matches[1];
$icon = 'baidu';
}elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'UCWEB '. $matches[1];
$icon = 'ucweb';
}elseif (preg_match('#Firefox/([a-zA-Z0-9.]+)#i', $ua, $matches)){
$title = 'Firefox '. $matches[1];
$icon = 'firefox';
}elseif (preg_match('#CriOS/([a-zA-Z0-9.]+)#i', $ua, $matches)){
$title = 'Chrome for iOS '. $matches[1];
$icon = 'crios';
}elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Google Chrome '. $matches[1];
$icon = 'chrome';
if (preg_match('#OPR/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Opera '. $matches[1];
$icon = 'opera15';
if (preg_match('#opera mini#i', $ua)) $title = 'Opera Mini'. $matches[1];
function siren_get_browsers(string $ua):array{
$title = 'Unknow';
$icon = 'unknown';
if (strpos($ua, 'Chrome')){
if (preg_match('#Chrome/([0-9]+)#i', $ua, $matches)) {
$title = 'Chrome '. $matches[1];
$icon = 'chrome';
if (preg_match('#Edg/([0-9]+)#i', $ua, $matches)){
$title = 'Edge '. $matches[1];
$icon = 'edge';
}
if (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = '360 Browser '. $matches[1];
$icon = '360se';
}
if (preg_match('#OPR/([0-9]+)#i', $ua, $matches)) {
$title = 'Opera '. $matches[1];
$icon = 'opera';
}
}
}elseif (strpos($ua, 'Firefox')){
if (preg_match('#Firefox/([0-9]+)#i', $ua, $matches)){
$title = 'Firefox '. $matches[1];
$icon = 'firefox';
}
}elseif (strpos($ua, 'Safari')){
if (preg_match('#Safari/([0-9]+)#i', $ua, $matches)) {
$title = 'Safari '. $matches[1];
$icon = 'safari';
}
}elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Safari '. $matches[1];
$icon = 'safari';
}elseif (preg_match('#Opera.(.*)Version[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
$title = 'Opera '. $matches[2];
$icon = 'opera';
if (preg_match('#opera mini#i', $ua)) $title = 'Opera Mini'. $matches[2];
}elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua,$matches)) {
$title = 'Maxthon '. $matches[2];
$icon = 'maxthon';
}elseif(preg_match('#wp-(iphone|android)/([a-zA-Z0-9.]+)#i', $ua, $matches)){ // 1.2 增加 wordpress 客户端的判断
$title = 'wordpress '. $matches[2];
$icon = 'wordpress';
}

return array(
$title,
$icon
);
return [
'title' => $title,
'icon' => $icon
];
}

// 操作系统信息
function siren_get_os($ua){
$title = 'unknow';
$icon = 'unknow';
if (preg_match('/win/i', $ua)) {
function siren_get_os(string $ua):array{
$title = 'Unknow';
$icon = 'unknown';
if (strpos($ua, 'Win')) {
if (preg_match('/Windows NT 10.0/i', $ua)) {
$title = "Windows 10/11";
$icon = "windows_win10_win11";
$icon = "win10-11";
}elseif (preg_match('/Windows NT 6.1/i', $ua)) {
$title = "Windows 7";
$icon = "windows_win7";
}elseif (preg_match('/Windows NT 5.1/i', $ua)) {
$title = "Windows XP";
$icon = "windows";
$icon = "win7";
}elseif (preg_match('/Windows NT 6.2/i', $ua)) {
$title = "Windows 8";
$icon = "windows_win8";
$icon = "win8";
}elseif (preg_match('/Windows NT 6.3/i', $ua)) {
$title = "Windows 8.1";
$icon = "windows_win8";
}elseif (preg_match('/Windows NT 6.0/i', $ua)) {
$title = "Windows Vista";
$icon = "windows_vista";
}elseif (preg_match('/Windows NT 5.2/i', $ua)) {
if (preg_match('/Win64/i', $ua)) {
$title = "Windows XP 64 bit";
} else {
$title = "Windows Server 2003";
}
$icon = 'windows';
}elseif (preg_match('/Windows Phone/i', $ua)) {
$matches = explode(';',$ua);
$title = $matches[2];
$icon = "windows_phone";
$icon = "win8";
}
}elseif (preg_match('#iPod.*.CPU.([a-zA-Z0-9.( _)]+)#i', $ua, $matches)) {
$title = "iPod ".$matches[1];
$icon = "iphone";
} elseif (preg_match('#iPhone OS ([a-zA-Z0-9.( _)]+)#i', $ua, $matches)) {// 1.2 修改成 iphone os 来判断
$title = "Iphone ".$matches[1];
$icon = "iphone";
} elseif (preg_match('#iPad.*.CPU.([a-zA-Z0-9.( _)]+)#i', $ua, $matches)) {
$title = "iPad ".$matches[1];
$icon = "ipad";
} elseif (preg_match('/Android.([0-9. _]+)/i', $ua, $matches)) {
}elseif (preg_match('#iPhone OS ([0-9]+)#i', $ua, $matches)) {// 1.2 修改成 iphone os 来判断
$title = "iOS ".$matches[1];
$icon = "apple";
}elseif (preg_match('/Android.([0-9. _]+)/i', $ua, $matches)) {
if(count(explode(7,$matches[1]))>1) $matches[1] = 'Lion '.$matches[1];
elseif(count(explode(8,$matches[1]))>1) $matches[1] = 'Mountain Lion '.$matches[1];
$title= $matches[0];
$icon = "android";
} elseif (preg_match('/Mac OS X.([0-9. _]+)/i', $ua, $matches)) {
if(count(explode(7,$matches[1]))>1) $matches[1] = 'Lion '.$matches[1];
elseif(count(explode(8,$matches[1]))>1) $matches[1] = 'Mountain Lion '.$matches[1];
$title = "Mac OSX ".$matches[1];
$icon = "macos";
} elseif (preg_match('/Mac OS X.([\d. _]+)/i', $ua, $matches)) {
$mac_ver = intval(explode('_',$matches[1])[1]);
$mac_code_name = '';
$has_x = $mac_ver <12;
$mac_code_list = ['Cheetah','Puma','Jaguar','Panther','Tiger','Leopard','Snow Leopard','Lion','Mountain Lion','Mavericks','Yosemite','El Capitan','Sierra','High Sierra','Mojave','Catalina or Higher']; // 总16个,后续请在最后添加并且修改该条注释.
if (isset($mac_code_list[$mac_ver])) {
$mac_code_name = $mac_code_list[$mac_ver];
}
$matches[1] = $mac_code_name.' '.$matches[1];
$title = 'macOS '.($has_x?'X':''.' ').str_replace('_','.',$matches[1]);;
$icon = "apple";
} elseif (preg_match('/Macintosh/i', $ua)) {
$title = "Mac OS";
$icon = "macos";
} elseif (preg_match('/CrOS/i', $ua)){
$title = "Google Chrome OS";
$icon = "chrome";
}elseif (preg_match('/Linux/i', $ua)) {
$title = "macOS";
$icon = "apple";
} elseif (preg_match('/Linux/i', $ua)) {
$title = 'Linux';
$icon = 'linux';
if (preg_match('/Android.([0-9. _]+)/i',$ua, $matches)) {
$title= $matches[0];
$icon = "android";
}elseif (preg_match('#Ubuntu#i', $ua)) {
$title = "Ubuntu Linux";
$icon = "ubuntu";
}elseif(preg_match('#Debian#i', $ua)) {
$title = "Debian GNU/Linux";
$icon = "debian";
}elseif (preg_match('#Fedora#i', $ua)) {
$title = "Fedora Linux";
$icon = "fedora";
}
}
return array(
$title,
$icon
);
return [
'title' => $title,
'icon' => $icon
];
}

function siren_get_useragent($ua){
if(iro_opt('comment_useragent')){
// $imgurl = get_bloginfo('template_directory') . '/images/ua/';
$imgurl = 'https://cdn.jsdelivr.net/gh/Fuukei/Public_Repository@latest/vision/ua/svg/';
$imgurl = 'https://cdn.jsdelivr.net/gh/Fuukei/Sakurairo_Vision@latest/ua/';
$browser = siren_get_browsers($ua);
$os = siren_get_os($ua);
return '&nbsp;&nbsp;<span class="useragent-info">( <img src="'. $imgurl.$browser[1] .'.svg">&nbsp;'. $browser[0] .'&nbsp;&nbsp;<img src="'. $imgurl.$os[1] .'.svg">&nbsp;'. $os[0] .' )</span>';
return '&nbsp;&nbsp;<span class="useragent-info">( <img src="'. $imgurl.$browser['icon'] .'.svg">&nbsp;'. $browser['title'] .'&nbsp;&nbsp;<img src="'. $imgurl.$os['icon'] .'.svg">&nbsp;'. $os['title'] .' )</span>';
}
return false;
}

// UA 显示移动定制
function mobile_get_useragent_icon($ua){
if(iro_opt('comment_useragent')){
$imgurl = 'https://cdn.jsdelivr.net/gh/Fuukei/Public_Repository@latest/vision/ua/svg/';
$imgurl = 'https://cdn.jsdelivr.net/gh/Fuukei/Sakurairo_Vision@latest/ua/';
$browser = siren_get_browsers($ua);
$os = siren_get_os($ua);
return '<span class="useragent-info-m">( <img src="'. $imgurl.$browser[1] .'.svg">&nbsp;&nbsp;<img src="'. $imgurl.$os[1] .'.svg"> )</span>';
return '<span class="useragent-info-m">( <img src="'. $imgurl.$browser['icon'] .'.svg">&nbsp;&nbsp;<img src="'. $imgurl.$os['icon'] .'.svg"> )</span>';
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion js/631.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/631.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 64d8921

Please sign in to comment.