From 8c90429a540a6dc6180069ca9e39449224d9234d Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Fri, 10 Sep 2021 14:24:11 +0800 Subject: [PATCH] feat: add a custom Gravatar mirror source --- inc/theme-core.php | 10 ++-------- inc/theme-options.php | 16 ++++++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/inc/theme-core.php b/inc/theme-core.php index 933c62c..f2ca5a6 100644 --- a/inc/theme-core.php +++ b/inc/theme-core.php @@ -4,7 +4,7 @@ * 核心函数 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2021.08.21 + * @version 2021.09.10 */ // CDN 资源地址 @@ -182,13 +182,7 @@ add_filter('style_loader_src', function ($href) { // 替换国内 Gravatar 源 function get_https_avatar($avatar) { - if (kratos_option('g_gravatar', true)) { - $cdn = "dn-qiniu-avatar.qbox.me"; - } else { - $cdn = "cn.gravatar.com"; - } - - $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com", "3.gravatar.com", "secure.gravatar.com"), $cdn, $avatar); + $avatar = str_replace(array("www.gravatar.com", "0.gravatar.com", "1.gravatar.com", "2.gravatar.com", "3.gravatar.com", "secure.gravatar.com"), kratos_option('g_gravatar', 'sdn.geekzu.org') ?: "secure.gravatar.com", $avatar); $avatar = str_replace("http://", "https://", $avatar); return $avatar; } diff --git a/inc/theme-options.php b/inc/theme-options.php index fbdafe2..c91dec7 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -4,7 +4,7 @@ * 主题选项 * @author Seaton Jiang * @license GPL-3.0 License - * @version 2021.08.21 + * @version 2021.09.10 */ defined('ABSPATH') || exit; @@ -150,13 +150,6 @@ CSF::createSection($prefix, array( 'subtitle' => __('启用/禁用静态资源加速', 'kratos'), 'default' => true, ), - array( - 'id' => 'g_gravatar', - 'type' => 'switcher', - 'title' => __('Gravatar 加速', 'kratos'), - 'subtitle' => __('启用/禁用 Gravatar 头像加速', 'kratos'), - 'default' => true, - ), array( 'id' => 'g_renameimg', 'type' => 'switcher', @@ -185,6 +178,13 @@ CSF::createSection($prefix, array( 'subtitle' => __('文章简介显示的字符数量', 'kratos'), 'default' => '260', ), + array( + 'id' => 'g_gravatar', + 'type' => 'text', + 'title' => __('Gravatar 加速', 'kratos'), + 'subtitle' => __('自定义 Gravatar 头像加速地址', 'kratos'), + 'default' => 'sdn.geekzu.org', + ), array( 'id' => 'g_renameother_fieldset', 'type' => 'fieldset',