* @license MIT License * @version 2021.08.19 */ defined('ABSPATH') || exit; $prefix = 'kratos_options'; if (!function_exists('kratos_option')) { function kratos_option($option = '', $default = null) { $options = get_option('kratos_options'); return (isset($options[$option])) ? $options[$option] : $default; } } function getdomain($url) { $rs = parse_url($url); if (!isset($rs['host'])) { return null; } $main_url = $rs['host']; if (!strcmp(long2ip(sprintf('%u', ip2long($main_url))), $main_url)) { return $main_url; } else { $arr = explode('.', $main_url); $count = count($arr); $endArr = array('com', 'net', 'org'); if (in_array($arr[$count - 2], $endArr)) { $domain = $arr[$count - 3] . '.' . $arr[$count - 2] . '.' . $arr[$count - 1]; } else { $domain = $arr[$count - 2] . '.' . $arr[$count - 1]; } return $domain; } } 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_bar_menu' => false, 'framework_title' => '主题设置Kratos v' . THEME_VERSION . '', 'theme' => 'light', 'footer_credit' => '感谢使用 Kratos 主题开始创作,欢迎加入交流群:734508', )); 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' => __('启用/禁用静态资源加速', 'kratos'), 'default' => true, ), array( 'id' => 'g_gravatar', 'type' => 'switcher', 'title' => __('Gravatar 加速', 'kratos'), 'subtitle' => __('启用/禁用 Gravatar 头像加速', 'kratos'), 'default' => true, ), 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_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' => '[' . getdomain(home_url()) . ']', '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_url', 'type' => 'upload', 'title' => __('二维码图片', 'kratos'), 'library' => 'image', 'preview' => true, 'subtitle' => __('浮动显示在页面右下角', 'kratos'), ), ), 'default' => array( 'g_wechat' => false, 'g_wechat_url' => get_template_directory_uri() . '/assets/img/wechat.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_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_tabbed', 'type' => 'tabbed', 'tabs' => array( array( 'title' => '轮播一', 'fields' => array( array( 'id' => 'c_i_1', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_u_1', 'type' => 'text', 'title' => __('网址链接', 'kratos'), ), ), ), array( 'title' => '轮播二', 'fields' => array( array( 'id' => 'c_i_2', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_u_2', 'type' => 'text', 'title' => __('网址链接', 'kratos'), ), ), ), array( 'title' => '轮播三', 'fields' => array( array( 'id' => 'c_i_3', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_u_3', 'type' => 'text', 'title' => __('网址链接', 'kratos'), ), ), ), array( 'title' => '轮播四', 'fields' => array( array( 'id' => 'c_i_4', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_u_4', 'type' => 'text', 'title' => __('网址链接', 'kratos'), ), ), ), array( 'title' => '轮播五', 'fields' => array( array( 'id' => 'c_i_5', 'type' => 'upload', 'title' => __('轮播图片', 'kratos'), 'library' => 'image', 'preview' => true, ), array( 'id' => 'c_u_5', 'type' => 'text', 'title' => __('网址链接', 'kratos'), ), ), ), ), ), ) )); CSF::createSection($prefix, array( 'parent' => 'global_fields', 'title' => __('第三方配置', 'kratos'), 'icon' => 'fas fa-arrow-right', 'fields' => array( 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, ), ), 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' ), ), ), )); 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' => 'html', ), 'sanitize' => false, 'default' => '', ), array( 'id' => 'seo_robots_fieldset', 'type' => 'fieldset', 'fields' => array( array( 'type' => 'subheading', 'content' => __('robots.txt 配置', 'kratos'), ), array( 'type' => 'content', 'content' => '