* @license GPL-3.0 License * @version 2025.02.08 */ defined('ABSPATH') || exit; $prefix = 'kratos_options'; if (!function_exists('kratos_option')) { function kratos_option($name, $default = false) { $options = get_option('kratos_options'); if (isset($options[$name])) { return $options[$name]; } return $default; } } function getrobots() { $site_url = parse_url(site_url()); $web_url = get_bloginfo('url'); $path = (!empty($site_url['path'])) ? $site_url['path'] : ''; $robots = "User-agent: *\n\n"; $robots .= "Disallow: $path/wp-admin/\n"; $robots .= "Disallow: $path/wp-includes/\n"; $robots .= "Disallow: $path/wp-content/plugins/\n"; $robots .= "Disallow: $path/wp-content/themes/\n\n"; $robots .= "Sitemap: $web_url/wp-sitemap.xml\n"; return $robots; } CSF::createOptions($prefix, array( 'menu_title' => __('主题设置', 'kratos'), 'menu_slug' => 'kratos-options', 'show_search' => false, 'show_all_options' => false, 'sticky_header' => false, 'admin_bar_menu_icon' => 'dashicons-admin-generic', 'framework_title' => '主题设置Kratos v' . THEME_VERSION . '', 'theme' => 'light', 'footer_credit' => '感谢使用 Kratos 主题进行创作,欢迎加入主题交流群:315990636', )); CSF::createSection($prefix, array( 'id' => 'global_fields', 'title' => __('全站配置', 'kratos'), 'icon' => 'fas fa-rocket', )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('功能配置', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( array( 'id' => 'g_adminbar', 'type' => 'switcher', 'title' => __('前台管理员导航', 'kratos'), 'subtitle' => __('启用/禁用前台管理员导航', 'kratos'), 'default' => true, ), array( 'id' => 'g_login', 'type' => 'switcher', 'title' => __('侧边栏后台入口', 'kratos'), 'subtitle' => __('启用/禁用个人简介头像进入后台功能', 'kratos'), 'default' => true, ), array( 'id' => 'g_sticky', 'type' => 'switcher', 'title' => __('侧边栏随动', 'kratos'), 'subtitle' => __('启用/禁用小工具侧边栏随动功能', 'kratos'), 'default' => false, ), array( 'id' => 'g_search', 'type' => 'switcher', 'title' => __('搜索增强', 'kratos'), 'subtitle' => __('启用/禁用仅搜索文章标题', 'kratos'), 'default' => false, ), array( 'id' => 'g_thumbnail', 'type' => 'switcher', 'title' => __('特色图片', 'kratos'), 'subtitle' => __('启用/禁用文章特色图片', 'kratos'), 'default' => true, ), array( 'id' => 'g_rip', 'type' => 'switcher', 'title' => __('哀悼功能', 'kratos'), 'subtitle' => __('启用/禁用站点首页黑白功能', 'kratos'), 'default' => false, ), array( 'id' => 'g_animate', 'type' => 'switcher', 'title' => __('CSS 动画库', 'kratos'), 'subtitle' => __('启用/禁用 animate.css 效果', 'kratos'), 'default' => false, ), array( 'id' => 'g_fontawesome', 'type' => 'switcher', 'title' => __('Font Awesome', 'kratos'), 'subtitle' => __('启用/禁用 Font Awesome Free 字体', 'kratos'), 'default' => false, ), array( 'id' => 'g_cdn', 'type' => 'switcher', 'title' => __('静态资源加速', 'kratos'), 'subtitle' => __('启用/禁用静态资源加速(jsDelivr)', 'kratos'), 'default' => false, ), array( 'id' => 'g_renameimg', 'type' => 'switcher', 'title' => __('自定义图片类型的文件名', 'kratos'), 'subtitle' => __('启用/禁用 图片类型的文件名改为 MD5 值', 'kratos'), 'default' => false, ), array( 'id' => 'g_removeimgsize', 'type' => 'switcher', 'title' => __('禁止生成缩略图', 'kratos'), 'subtitle' => __('启用/禁用生成多种尺寸图片资源', 'kratos'), 'default' => false, ), array( 'id' => 'g_gutenberg', 'type' => 'switcher', 'title' => __('Gutenberg 编辑器', 'kratos'), 'subtitle' => __('启用/禁用 Gutenberg 编辑器', 'kratos'), 'default' => false, ), array( 'id' => 'g_page_lightgallery', 'type' => 'switcher', 'title' => __('页面图片灯箱', 'kratos'), 'subtitle' => __('启用/禁用页面图片灯箱功能', 'kratos'), 'default' => true, ), array( 'id' => 'g_excerpt_length', 'type' => 'text', 'title' => __('文章简介缩略', 'kratos'), 'subtitle' => __('文章简介显示的字符数量', 'kratos'), 'default' => '260', ), array( 'id' => 'g_replace_gravatar_url_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('Gravatar 加速服务', 'kratos'), ), array( 'id' => 'g_replace_gravatar_url', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭 Gravatar 加速服务功能', 'kratos'), ), array( 'id' => 'g_select_gravatar_server', 'type' => 'select', 'title' => __('Gravatar 加速服务地址', 'kratos'), 'subtitle' => __('请选择 Gravatar 加速服务地址', 'kratos'), 'options' => array( 'loli' => __('Loli 加速服务', 'kratos'), 'geekzu' => __('极客族加速服务', 'kratos'), 'other' => __('自定义加速服务', 'kratos'), ), 'desc' => __('国内用户推荐「极客族加速服务」,海外用户推荐「Loli 加速服务」。', 'kratos'), 'dependency' => array('g_replace_gravatar_url', '==', 'true'), ), array( 'id' => 'g_custom_gravatar_server', 'type' => 'text', 'title' => __('自定义 Gravatar 加速服务地址', 'kratos'), 'subtitle' => __('请输入 Gravatar 加速服务地址', 'kratos'), 'desc' => __('直接输入网址即可,不需要协议头和最后的斜杠。', 'kratos'), 'placeholder' => 'secure.gravatar.com', 'dependency' => array('g_replace_gravatar_url|g_select_gravatar_server', '==|==', 'true|other'), ), ), 'default' => array( 'g_replace_gravatar_url' => 1, 'g_select_gravatar_server' => 'geekzu', ) ), array( 'id' => 'g_renameother_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('附件重命名', 'kratos'), ), array( 'id' => 'g_renameother', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭附件重命名', 'kratos'), 'text_on' => __('开启', 'kratos'), 'text_off' => __('关闭', 'kratos'), ), array( 'id' => 'g_renameother_prdfix', 'type' => 'text', 'title' => __('文件前缀', 'kratos'), 'subtitle' => __('前缀与文件名之间会用 - 连接', 'kratos'), ), array( 'id' => 'g_renameother_mime', 'type' => 'text', 'title' => __('文件类型', 'kratos'), 'subtitle' => __('每个类型之间用 | 隔开', 'kratos'), ), ), 'default' => array( 'g_renameother' => false, 'g_renameother_prdfix' => 'kratos', 'g_renameother_mime' => 'tar|zip|gz|gzip|rar|7z', ), ), array( 'id' => 'g_wechat_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('微信二维码', 'kratos'), ), array( 'id' => 'g_wechat', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭微信二维码', 'kratos'), 'text_on' => __('开启', 'kratos'), 'text_off' => __('关闭', 'kratos'), ), array( 'id' => 'g_wechat_img', 'type' => 'upload', 'title' => __('二维码图片', 'kratos'), 'library' => 'image', 'preview' => true, 'subtitle' => __('浮动显示在页面右下角', 'kratos'), ), ), 'default' => array( 'g_wechat' => false, 'g_wechat_img' => get_template_directory_uri() . '/assets/img/200.png', ), ), ), )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('颜色配置', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( array( 'id' => 'g_background', 'type' => 'color', 'default' => '#f5f5f5', 'title' => __('全站背景颜色', 'kratos'), 'subtitle' => __('全站页面的背景颜色', 'kratos'), ), array( 'id' => 'g_nav', 'type' => 'color', 'default' => '#ffffff', 'title' => __('导航栏文字颜色', 'kratos'), 'subtitle' => __('导航栏中站点标题以及一级导航的颜色', 'kratos'), ), array( 'id' => 'g_chrome', 'type' => 'color', 'default' => '#282a2c', 'title' => __('Chrome 导航栏颜色', 'kratos'), 'subtitle' => __('移动端 Chrome 浏览器导航栏颜色', 'kratos'), ), ), )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('图片配置', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( array( 'id' => 'g_logo', 'type' => 'upload', 'title' => __('站点 Logo', 'kratos'), 'library' => 'image', 'preview' => true, 'subtitle' => __('不上传图片则显示站点标题', 'kratos'), ), array( 'id' => 'g_icon', 'type' => 'upload', 'title' => __('Favicon 图标', 'kratos'), 'library' => 'image', 'preview' => true, 'subtitle' => __('浏览器收藏夹和地址栏中显示的图标', 'kratos'), ), array( 'id' => 'g_404', 'type' => 'upload', 'title' => __('404 页面图片', 'kratos'), 'library' => 'image', 'preview' => true, 'default' => get_template_directory_uri() . '/assets/img/404.jpg', 'subtitle' => __('图片显示出来是 404 的形状', 'kratos'), ), array( 'id' => 'g_nothing', 'type' => 'upload', 'title' => __('无内容图片', 'kratos'), 'library' => 'image', 'preview' => true, 'default' => get_template_directory_uri() . '/assets/img/nothing.svg', 'subtitle' => __('当搜索不到文章或分类没有文章时显示', 'kratos'), ), array( 'id' => 'g_postthumbnail', 'type' => 'upload', 'title' => __('默认特色图', 'kratos'), 'library' => 'image', 'preview' => true, 'default' => get_template_directory_uri() . '/assets/img/default.jpg', 'subtitle' => __('当文章中没有图片且没有特色图时显示', 'kratos'), ), ), )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('首页轮播', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( array( 'id' => 'g_carousel', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭首页轮播功能', 'kratos'), 'text_on' => __('开启', 'kratos'), 'text_off' => __('关闭', 'kratos'), 'default' => false, ), array( 'id' => 'carousel_group', 'type' => 'group', 'title' => '首页轮播', 'subtitle' => '点击添加轮播内容,最多添加 7 个轮播内容', 'min' => 1, 'max' => 7, 'fields' => array( array( 'id' => 'c_id', 'type' => 'text', 'title' => __('唯一标识', 'kratos'), 'subtitle' => __('仅用于轮播标识,可以作为备注使用', 'kratos'), ), array( 'id' => 'c_img', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'subtitle' => __('可以直接填写图片链接,也可以上传图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_url', 'type' => 'text', 'title' => __('网址链接', 'kratos'), 'subtitle' => __('需要填写完整的链接地址,包含协议头', 'kratos'), ), array( 'id' => 'c_title', 'type' => 'text', 'title' => __('轮播标题', 'kratos'), 'subtitle' => __('选填项目,如果不填则不显示', 'kratos'), ), array( 'id' => 'c_subtitle', 'type' => 'textarea', 'title' => __('轮播简介', 'kratos'), 'subtitle' => __('选填项目,如果不填则不显示', 'kratos'), ), array( 'id' => 'c_color', 'type' => 'color', 'default' => '#000', 'title' => __('文字颜色', 'kratos'), 'subtitle' => __('轮播标题和简介的颜色', 'kratos'), ), ), ), ) )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('第三方配置', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( array( 'type' => 'notice', 'style' => 'info', 'content' => '提示:DogeCloud 云存储 与 火山引擎 ImageX请勿同时开启!', ), array( 'id' => 'g_cos_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('DogeCloud 云存储', 'kratos'), ), array( 'type' => 'submessage', 'style' => 'info', 'content' => 'DogeCloud 云存储提供 10 GB 的免费存储额度, 20 GB 每月的免费 CDN 额度,立即注册', ), array( 'id' => 'g_cos', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭 DogeCloud 云存储', 'kratos'), 'text_on' => __('开启', 'kratos'), 'text_off' => __('关闭', 'kratos'), ), array( 'id' => 'g_cos_bucketname', 'type' => 'text', 'title' => __('空间名称', 'kratos'), 'subtitle' => __('空间名称可在空间基本信息中查看', 'kratos'), 'desc' => __('点击这里查询空间名称', 'kratos'), ), array( 'id' => 'g_cos_url', 'type' => 'text', 'title' => __('加速域名', 'kratos'), 'subtitle' => __('域名结尾不要添加 /', 'kratos'), 'desc' => __('点击这里查询加速域名', 'kratos'), ), array( 'id' => 'g_cos_accesskey', 'type' => 'text', 'title' => __('AccessKey', 'kratos'), 'subtitle' => __('出于安全考虑,建议周期性地更换密钥', 'kratos'), 'desc' => __('点击这里查询 AccessKey', 'kratos'), ), array( 'id' => 'g_cos_secretkey', 'type' => 'text', 'attributes' => array( 'type' => 'password', ), 'title' => __('SecretKey', 'kratos'), 'subtitle' => __('出于安全考虑,建议周期性地更换密钥', 'kratos'), 'desc' => __('点击这里查询 SecretKey', 'kratos'), ), ), 'default' => array( 'g_cos' => false, 'g_cos_bucketname' => '', 'g_cos_url' => '', 'g_cos_accesskey' => '', 'g_cos_secretkey' => '', ), ), array( 'id' => 'g_imgx_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('火山引擎 ImageX', 'kratos'), ), array( 'type' => 'submessage', 'style' => 'info', 'content' => '火山引擎 ImageX 提供 10 GB 的免费存储额度, 10 GB 每月的免费 CDN 额度, 20 TB 每月的图像处理额度,立即注册', ), array( 'id' => 'g_imgx', 'type' => 'switcher', 'title' => __('功能开关', 'kratos'), 'subtitle' => __('开启/关闭 火山引擎 ImageX', 'kratos'), 'text_on' => __('开启', 'kratos'), 'text_off' => __('关闭', 'kratos'), ), array( 'id' => 'g_imgx_region', 'type' => 'select', 'title' => __('加速地域', 'kratos'), 'subtitle' => __('加速地域在创建服务的时候进行选择', 'kratos'), 'desc' => __('点击这里查询加速地域', 'kratos'), 'options' => array( 'cn-north-1' => __('国内', 'kratos'), 'us-east-1' => __('美东', 'kratos'), 'ap-singapore-1' => __('新加坡', 'kratos') ), ), array( 'id' => 'g_imgx_serviceid', 'type' => 'text', 'title' => __('服务 ID', 'kratos'), 'subtitle' => __('服务 ID 可在图片服务管理中查看', 'kratos'), 'desc' => __('点击这里查询服务 ID', 'kratos'), ), array( 'id' => 'g_imgx_url', 'type' => 'text', 'title' => __('加速域名', 'kratos'), 'subtitle' => __('域名结尾不要添加 /', 'kratos'), 'desc' => __('点击这里查询加速域名', 'kratos'), ), array( 'id' => 'g_imgx_tmp', 'type' => 'text', 'title' => __('处理模板', 'kratos'), 'subtitle' => __('处理模板可在图片处理配置中查看', 'kratos'), 'desc' => __('点击这里查询处理模板', 'kratos'), ), array( 'id' => 'g_imgx_accesskey', 'type' => 'text', 'title' => __('AccessKey', 'kratos'), 'subtitle' => __('出于安全考虑,建议周期性地更换密钥', 'kratos'), 'desc' => __('点击这里查询 AccessKey', 'kratos'), ), array( 'id' => 'g_imgx_secretkey', 'type' => 'text', 'attributes' => array( 'type' => 'password', ), 'title' => __('SecretKey', 'kratos'), 'subtitle' => __('出于安全考虑,建议周期性地更换密钥', 'kratos'), 'desc' => __('点击这里查询 SecretKey', 'kratos'), ), ), 'default' => array( 'g_imgx' => false, 'g_imgx_region' => 'cn-north-1', "g_imgx_serviceid" => "", "g_imgx_url" => "", "g_imgx_tmp" => "", "g_imgx_accesskey" => "", "g_imgx_secretkey" => "", ), ), ), )); CSF::createSection($prefix, array( 'title' => __('收录配置', 'kratos'), 'icon' => 'fas fa-camera', 'fields' => array( array( 'id' => 'seo_shareimg', 'type' => 'upload', 'title' => __('分享图片', 'kratos'), 'library' => 'image', 'preview' => true, 'default' => get_template_directory_uri() . '/assets/img/default.jpg', 'subtitle' => __('用于搜索引擎或社交工具抓取时使用', 'kratos'), ), array( 'id' => 'seo_keywords', 'type' => 'text', 'title' => __('关键词', 'kratos'), 'subtitle' => __('每个关键词之间需要用 , 分割', 'kratos'), ), array( 'id' => 'seo_description', 'type' => 'textarea', 'title' => __('站点描述', 'kratos'), 'subtitle' => __('网站首页的描述信息', 'kratos'), ), array( 'id' => 'seo_statistical', 'title' => __('统计代码', 'kratos'), 'subtitle' => __('输入代码时请注意辨别代码安全性', 'kratos'), 'type' => 'code_editor', 'settings' => array( 'theme' => 'default', 'mode' => 'htmlmixed', ), 'sanitize' => false, 'default' => '', ), array( 'id' => 'seo_robots_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('robots.txt 配置', 'kratos'), ), array( 'type' => 'content', 'content' => '