Files
wordpress-kratos-yang/inc/theme-options.php
T
laoyang cbe0f2dc59 3.2.18: 清明按节气换算、主题内 [TOC] 目录、重建评论区替代 wpDiscuz
三项功能:

1. 清明不再用固定 04-04
   清明是节气,日期在 4/4~4/6 之间浮动。硬编码 04-04 实测 1900-2100
   共 201 年里只有 76 年是对的(约 38%)。改为内嵌逐年表换算真实日期,
   超出 1900-2100 返回 null 明确放弃,不退化成近似值。
   兼容 3.2.17 及以前勾过的 '04-04' 键,升级后勾选不会被静默丢弃。

2. 主题内实现 [TOC]
   文章里写 [TOC],该位置输出本文目录,点击跳到对应标题。
   在 the_content 优先级 9 处理(早于 wpautop 10 / do_shortcode 11),
   保证"补 id"与"扫目录"用的是同一份文本,href 与 id 必然对得上。
   嵌套用深度归一化,h1→h3 跳级不会算错层级。
   scroll-margin-top 声明式让位,原生锚点/外部 #hash/后退全都生效。

3. 重建评论区
   旧实现的问题:列表渲染与 AJAX 渲染各写一份 HTML,已经分叉
   (AJAX 返回的新评论没有回复按钮);<li> 被 <div> 包着,嵌套回复错位。
   现在统一到 yang_comment_html() 单一渲染函数,列表与 AJAX 只差一个
   is-new 类。同时修掉三处真实缺陷:
     · 评论项用 flex 会把 <ol class="yang-children"> 当成第三个 flex 项,
       子评论跑到父评论右侧、正文被挤到 156px、页面横向溢出 75px —— 改 grid
     · 成功提示在 exitReplyMode() 之前设置,被其末尾的 setStatus('','')
       擦掉,用户提交成功却看不到反馈 —— 调整顺序
     · 窄屏媒体查询打不过深层选择器(媒体查询不增加特异性),
       嵌套头像反向变大 —— 补深层覆盖

   与 wpDiscuz 解耦:邮件模块不再无条件 return false(那等于永久关掉
   notify_postauthor 且不报错);插件在场时不加载主题评论资源,
   避免双份表单互抢。

验证:PHP 语法 73/73;_static_qingming 36、_test_toc 53、
_test_comments 62、_test_comments_falsify 17、
_toc_geometry 121、_toc_geometry_falsify 9、
_comments_geometry 98、_comments_geometry_falsify 23,全部 0 失败。
线上端到端 29/0(真实文章渲染目录 + 真实评论数据渲染)。
2026-10-24 01:03:36 +08:00

705 lines
28 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* 主题选项
*
* ── 分类原则(3.2.15 重排)────────────────────────────────────
* 原来九个头部分类里有几处明显错位:
* · 哀悼功能挂在「首页配置」下面 —— 它影响的是整站(首页、文章页、说明页),
* 跟首页没有关系;
* · 国旗、备案、版权拆在「页脚」但「404 图片」在全站,都是零碎的;
* · 「收录配置」把 robots.txt 一起塞进来,其实那是另一件事。
*
* 现在的顺序按「访客看到的顺序」排:整站基础 → 顶部 → 首页 → 文章 →
* 站长 → 页脚 → 专项功能 → 收录 → 邮件 → 自定义代码。
* 每一项只出现在它真正生效的地方,不再有"在首页配置里改整站行为"这种事。
*
* @author Yongquan Yang <yangyq.net>
* @license MIT License
* @version 2020.09.21
*/
function getrobots()
{
$site_url = parse_url(site_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";
return $robots;
}
/**
* 图片字段的默认值(后台预填用)。
*
* ── 为什么不直接调 yang_image_default() ──────────────────────
* 本文件由 optionsframework_init() 在 init 钩子上 require,
* 而 yang_image_default() 来自 inc/theme-option-defaults.php。
* 正常时序下后者先加载,但**加载顺序被打乱时**(子主题、外部脚本
* 直接 include 本文件、插件在更早的钩子里触发本函数),
* 直接调用就会 Fatal —— 后台整个白屏,比"少一个预填值"严重得多。
*
* 这里先用 function_exists() 探一下,缺了就返回空串:
* 后台退化成没有预填默认值,但页面能打开、能保存、能干活。
* 降级必须降到"还能用",不能降到"打不开"。
*/
if (!function_exists('yang_options_default_img')) {
function yang_options_default_img($id)
{
return function_exists('yang_image_default')
? yang_image_default($id)
: '';
}
}
/**
* 哀悼相关辅助函数的安全访问
*
* 同样的道理:yang_mourning_presets() / yang_mourning_status_text() /
* yang_mourning_extra_raw() 都在 inc/theme-mourning.php 里,由
* functions.php 按顺序 require。只要有人(子主题、迁移脚本、别的插件)
* 在 theme-mourning.php 之前触发了 kratos_options(),这里就会 Fatal,
* 整个后台白屏,且报错指向本文件,很难联想到是加载顺序问题。
*
* 降级策略:缺函数时按"没有纪念日 / 没有状态说明"降级 ——
* 后台那几个控件会变空,但页面能打开、能保存、能继续用。
*/
if (!function_exists('yang_opt_mourning_presets')) {
function yang_opt_mourning_presets()
{
return function_exists('yang_mourning_presets')
? yang_mourning_presets()
: array();
}
}
if (!function_exists('yang_opt_mourning_status')) {
function yang_opt_mourning_status()
{
return function_exists('yang_mourning_status_text')
? yang_mourning_status_text()
: '';
}
}
if (!function_exists('yang_opt_mourning_extra_raw')) {
function yang_opt_mourning_extra_raw()
{
return function_exists('yang_mourning_extra_raw')
? yang_mourning_extra_raw()
: '';
}
}
/**
* 今年清明的月日,给后台说明文字用(如「4 月 5 日」)
*
* 换算不出来(超出年份表范围)时返回一句明确的说明,
* **不要**退化成「4 月 4 日」—— 那正是用户要求删掉的近似值。
*/
if (!function_exists('yang_opt_qingming_label')) {
function yang_opt_qingming_label()
{
if (!function_exists('yang_qingming_md')) {
return __('换算不可用', 'kratos');
}
$md = yang_qingming_md();
if ($md === null) {
return sprintf(
__('今年(%s 年)超出可换算范围,清明不会自动生效', 'kratos'),
current_time('Y')
);
}
list($mo, $da) = explode('-', $md);
return sprintf(__('%d 月 %d 日', 'kratos'), (int) $mo, (int) $da);
}
}
/**
* 自定义 CSS 的默认值(来自 inc/theme-custom-code.php)
*
* 同样是加载顺序问题:这个函数在 theme-custom-code.php 里,
* 而 kratos_options() 可能被更早触发。缺了就返回空串,
* 后台的「自定义 CSS」框是空的,但能打开、能填、能保存。
*/
if (!function_exists('yang_opt_default_custom_css')) {
function yang_opt_default_custom_css()
{
return function_exists('yang_default_custom_css')
? yang_default_custom_css()
: '';
}
}
function kratos_options()
{
$sitename = get_bloginfo('name');
$imagepath = ASSET_PATH . '/assets/img/options/';
$seorobots = '<a href="' . home_url() . '/robots.txt" target="_blank">robots.txt</a>';
$seoreading = '<a href="' . admin_url('options-reading.php') . '" target="_blank">' . __('设置-阅读-对搜索引擎的可见性', 'kratos') . '</a>';
$top_array = array(
'banner' => __( '图片导航', 'kratos' ),
'color' => __( '颜色导航', 'kratos' ),
);
$options = array();
/* ══════════════════════════════════════════════════════════
* 一、全站配置 —— 影响每一个页面的东西
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('全站配置', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('图片 Logo', 'kratos'),
'desc' => __('不选择图片则显示文字标题', 'kratos'),
'id' => 'g_logo',
'type' => 'upload',
/* 有意不设 std:这里空着时显示站点名称文字,比塞一张通用占位
logo 好看。其它图片字段见 inc/theme-option-defaults.php。 */
);
$options[] = array(
'name' => __('Favicon 图片', 'kratos'),
'desc' => __('浏览器收藏夹和地址栏中显示的图标。<b>留空则自动使用主题自带的默认图标</b>,不会出现空白。', 'kratos'),
'id' => 'g_icon',
/* 有意不写 std。
*
* std 里存的是**绝对 URL**,一旦用户保存表单就会被写进数据库。
* 数据库里躺着一个写死的主题目录地址是隐患:主题目录改名、
* 换 CDN、或站点迁移域名之后,那条记录就指向不存在的文件,
* 页面上是破图,而用户在后台看到的仍是"已设置",很难自己发现。
*
* 所以默认值一律由运行时提供(yang_option_image()),库里保持空。
* 这样默认图地址永远由当前请求现算,改目录也不用改数据。
*/
'type' => 'upload',
);
$options[] = array(
'name' => __('背景颜色', 'kratos'),
'desc' => __('全站页面的背景颜色,需填写十六进制颜色码', 'kratos'),
'id' => 'g_background',
'std' => '#f5f5f5',
'type' => 'color',
);
$options[] = array(
'name' => __('Chrome 导航栏颜色', 'kratos'),
'desc' => __('Chrome 移动端浏览器地址栏的颜色', 'kratos'),
'id' => 'g_chrome',
'std' => '#282a2c',
'type' => 'color',
);
$options[] = array(
'name' => __('404 页面图片', 'kratos'),
'desc' => __('访客打开不存在的地址时显示的配图', 'kratos'),
'id' => 'g_404',
'std' => yang_options_default_img('g_404'),
'type' => 'upload',
);
$options[] = array(
'name' => __('前台管理员导航', 'kratos'),
'desc' => __('登录管理员后,页面顶部显示 WordPress 管理工具条', 'kratos'),
'std' => '1',
'id' => 'g_adminbar',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('CSS 动画库', 'kratos'),
'desc' => __('开启 animate.css 效果。会增加一个约 60KB 的样式文件,不需要就别开。', 'kratos'),
'std' => '0',
'id' => 'g_animate',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('Gravatar 加速', 'kratos'),
'desc' => __('把评论头像的请求转发到国内可访问的镜像,改善加载速度', 'kratos'),
'std' => '0',
'id' => 'g_gravatar',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('禁止生成缩略图', 'kratos'),
'desc' => __('上传图片时不再额外生成多种尺寸的副本,节省磁盘空间', 'kratos'),
'id' => 'g_removeimgsize',
'std' => '0',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('Gutenberg 编辑器', 'kratos'),
'desc' => __('开启 WordPress 区块编辑器。关闭则使用经典编辑器。', 'kratos'),
'std' => '0',
'id' => 'g_gutenberg',
'type' => 'checkbox',
);
/* ══════════════════════════════════════════════════════════
* 二、顶部导航 —— 页头那一条
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('顶部导航', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __( '顶部样式', 'kratos' ),
'desc' => __('请选择顶部样式(图片导航或颜色导航)', 'kratos'),
'id' => 'top_select',
'std' => 'banner',
'type' => 'select',
'options' => $top_array
);
$options[] = array(
'name' => __('图片导航背景', 'kratos'),
'desc' => __('顶部样式选「图片导航」时使用。<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'top_img',
'std' => yang_options_default_img('top_img'),
'class' => 'hidden',
'type' => 'upload',
);
$options[] = array(
'name' => __('颜色导航背景', 'kratos'),
'desc' => __('顶部样式选「颜色导航」时使用', 'kratos'),
'id' => 'top_color',
'std' => '#24292e',
'class' => 'hidden',
'type' => 'color',
);
$options[] = array(
'name' => __('副标题', 'kratos'),
'desc' => __('显示在站点标题旁边的一句短话', 'kratos'),
'id' => 'top_title',
'std' => 'Kratos',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('标题描述', 'kratos'),
'std' => __('一款专注于用户阅读体验的响应式博客主题', 'kratos'),
'id' => 'top_describe',
'class' => 'hidden',
'type' => 'text',
);
/* ══════════════════════════════════════════════════════════
* 三、首页配置 —— 只管首页列表长什么样
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('首页配置', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('特色图片', 'kratos'),
'desc' => __('在首页文章列表的每篇标题上方显示一张配图', 'kratos'),
'std' => '1',
'id' => 'g_thumbnail',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('默认特色图', 'kratos'),
'desc' => __('文章既没有正文图片、也没有设置特色图时,用这张顶上。<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'g_postthumbnail',
'class' => 'hidden',
'std' => yang_options_default_img('g_postthumbnail'),
'type' => 'upload',
);
$options[] = array(
'name' => __('无内容图片', 'kratos'),
'desc' => __('搜索不到结果、或分类下还没有文章时显示的插画。<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'g_nothing',
'std' => yang_options_default_img('g_nothing'),
'type' => 'upload',
);
/* ══════════════════════════════════════════════════════════
* 四、文章配置 —— 打开单篇文章才看得到的东西
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('文章配置', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('页面布局', 'kratos'),
'desc' => __('文章页面是否显示侧边栏。仅在文章详情页生效。', 'kratos'),
'id' => "g_article_widgets",
'std' => "two_side",
'type' => "images",
'options' => array(
'one_side' => $imagepath . 'col-12.png',
'two_side' => $imagepath . 'col-8.png')
);
$options[] = array(
'name' => __('文章打赏', 'kratos'),
'desc' => __('在文章底部显示打赏按钮,点开是收款二维码', 'kratos'),
'id' => 'g_donate',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('支付宝收款码', 'kratos'),
'desc' => __('<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'g_donate_alipay',
'std' => yang_options_default_img('g_donate_alipay'),
'type' => 'upload',
'class' => 'hidden',
);
$options[] = array(
'name' => __('微信收款码', 'kratos'),
'desc' => __('<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'g_donate_wechat',
'std' => yang_options_default_img('g_donate_wechat'),
'type' => 'upload',
'class' => 'hidden',
);
/* ══════════════════════════════════════════════════════════
* 五、站长信息 —— 文章页页脚那张名片
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('站长信息', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('个人头像', 'kratos'),
'desc' => __('显示在文章底部作者名片里。<b>留空则自动使用主题自带的默认头像</b>。', 'kratos'),
'id' => 'a_gravatar',
'std' => yang_options_default_img('a_gravatar'),
'type' => 'upload',
);
$options[] = array(
'name' => __('个人昵称', 'kratos'),
'id' => 'a_nickname',
'std' => 'Kratos',
'type' => 'text',
);
$options[] = array(
'name' => __('个人简介', 'kratos'),
'std' => __('保持饥渴的专注,追求最佳的品质', 'kratos'),
'id' => 'a_about',
'type' => 'textarea',
);
/* ══════════════════════════════════════════════════════════
* 六、页脚配置 —— 页面最底下那几行
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('页脚配置', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('版权信息', 'kratos'),
'desc' => __('页脚显示的那行版权声明。<b>留空则自动用「COPYRIGHT © 当前年份 站点名称 版权所有」</b>。', 'kratos'),
'id' => 's_copyright',
/* 有意不写 std:std 里写死的年份过一年就变成旧年份,
而且一旦保存就永久留在库里。改由 footer.php 每次现算。 */
'type' => 'textarea',
);
$options[] = array(
'name' => __('是否显示国旗', 'kratos'),
'desc' => __('在页脚显示一面国旗', 'kratos'),
'std' => '0',
'id' => 'g_flag',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('国旗图片', 'kratos'),
'desc' => __('<b>留空则自动使用主题自带的默认国旗</b>。', 'kratos'),
'id' => 'g_flag_url',
/* 不写 std —— 理由同 g_icon:默认值由运行时给,库里不存绝对地址。 */
'type' => 'upload',
);
$options[] = array(
'name' => __('工信部备案信息', 'kratos'),
'id' => 's_icp',
'placeholder' => __('例如:京ICP证xxxxxx号', 'kratos'),
'type' => 'text',
);
$options[] = array(
'name' => __('公安网备案信息', 'kratos'),
'id' => 's_gov',
'placeholder' => __('例如:京公网安备 xxxxxxxxxxxx号', 'kratos'),
'type' => 'text',
);
$options[] = array(
'name' => __('公安网备案链接', 'kratos'),
'id' => 's_gov_link',
'placeholder' => __('例如:http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=xxxxx', 'kratos'),
'type' => 'text',
);
/* ══════════════════════════════════════════════════════════
* 七、哀悼模式 —— 整站级功能,与首页无关
*
* 这一组原来错放在「首页配置」下面。它影响的是整站配色
* (首页、文章页、说明页都变黑白),放首页下面会让人以为
* 只改首页,而且想找它的人第一反应不会去点「首页配置」。
* 单独成组,名字直说它是什么。
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('哀悼模式', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('手动常开', 'kratos'),
'desc' => __('勾上就一直黑白,与日期无关。这是老的开关,日常建议用下面的「按纪念日自动哀悼」。', 'kratos'),
'id' => 'g_rip',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('按纪念日自动哀悼', 'kratos'),
'desc' => __('勾选后,只有在下表勾选的那些日期才会自动黑白,其余日子正常显示。日期按站点时区判断,只比对月和日,每年循环。', 'kratos'),
'id' => 'g_rip_auto',
'type' => 'checkbox',
);
// 把内置清单转成 multicheck 需要的格式
$rip_legal = array();
$rip_custom = array();
foreach (yang_opt_mourning_presets() as $key => $info) {
/* 键有两种:静态日期(`09-03`)和动态日期(`qingming`)。
动态日期的键是内部标识,不能直接摆在用户面前 ——
所以看 key_label,没有就回退到键本身(静态日期就是 MM-DD,
显示出来正好是用户认得的日期)。 */
$label = isset($info['key_label']) ? $info['key_label'] : $key;
$entry = array(
'name' => $label . ' ' . $info['name'],
'note' => $info['note'],
);
if (isset($info['group']) && $info['group'] === 'legal') {
$rip_legal[$key] = $entry;
} else {
$rip_custom[$key] = $entry;
}
}
$rip_default = array();
foreach (yang_opt_mourning_presets() as $key => $info) {
$rip_default[$key] = !empty($info['default']) ? 1 : 0;
}
$options[] = array(
'name' => __('纪念日清单', 'kratos'),
'desc' => sprintf(
__('勾选需要自动黑白的日期。<b>默认一个都不勾</b>,请按自己的意愿挑选。前三个是法定纪念日,后面几个是民间通行做法。日期按站点时区判断,只比对月和日,每年循环。<br><b>清明节</b>是节气,日期每年浮动(4 月 4~6 日之间),已脱离固定日期、按天文历逐年换算 —— 今年是 <b>%s</b>。', 'kratos'),
esc_html(yang_opt_qingming_label())
),
'id' => 'g_rip_days',
'std' => $rip_default,
'type' => 'multicheck',
'options' => array_merge($rip_legal, $rip_custom),
);
$options[] = array(
'name' => __('附加日期', 'kratos'),
'desc' => sprintf(
__('清单里没有的日期填这里。<br><b>%1$s</b> 表示每年循环(如 05-12);<b>%2$s</b> 表示只在当年生效(如 2020-04-04,用于历次全国哀悼日这类一次性事件)。<br>多个日期用空格或逗号分隔。当前填的是 <b>%3$s</b>。', 'kratos'),
'MM-DD',
'YYYY-MM-DD',
esc_html(yang_opt_mourning_extra_raw() === '' ? __('(空)', 'kratos') : yang_opt_mourning_extra_raw())
),
'id' => 'g_rip_extra',
'type' => 'text',
);
$options[] = array(
'name' => __('说明页路径', 'kratos'),
'desc' => sprintf(
/* 注意:desc 会过 wp_kses($allowedtags),那是 WordPress 的默认白名单,
只放行 a/abbr/b/br/em/i/strong 等,**不放行 <code>** ——
写 <code> 会被静默剥掉,页面上只剩裸文字。所以这里用 <b> 强调。 */
__('变黑白时,页面顶部会出现一条提示,点进去是一个说明页面(彩色),讲清楚为什么变黑白、哪几天会变。<br>这里可以改那个页面的路径。留空默认 <b>memory</b>,即 %s<br><b>注意:</b>不要和已有文章或页面的路径重名。', 'kratos'),
esc_url(home_url('/memory/'))
),
'id' => 'g_rip_page_slug',
'std' => 'memory',
'type' => 'text',
);
$options[] = array(
'desc' => yang_opt_mourning_status(),
'type' => 'info',
);
/* ══════════════════════════════════════════════════════════
* 八、收录与统计 —— 给搜索引擎看的
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('收录与统计', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('分享图片', 'kratos'),
'desc' => __('搜索引擎或者社交工具分享首页时抓取的图片。<b>留空则自动使用主题自带的默认图片</b>。', 'kratos'),
'id' => 'seo_shareimg',
'std' => yang_options_default_img('seo_shareimg'),
'type' => 'upload',
);
$options[] = array(
'name' => __('关键词', 'kratos'),
'desc' => __('每个关键词之间需要用「英文逗号」分割', 'kratos'),
'id' => 'seo_keywords',
'type' => 'text',
);
$options[] = array(
'name' => __('站点描述', 'kratos'),
'id' => 'seo_description',
'type' => 'textarea',
);
$options[] = array(
'name' => __('统计代码', 'kratos'),
'desc' => __('填在页脚的统计脚本(如站点访问量统计)。注意:输入 HTML/JS 代码时请注意辨别代码安全!', 'kratos'),
'id' => 'seo_statistical',
'type' => 'textarea',
);
$options[] = array(
'name' => __('robots.txt 内容', 'kratos'),
'desc' => __('- 需要 ', 'kratos') . $seoreading . __(' 是开启的状态,下面的配置才会生效', 'kratos'),
'type' => 'info',
);
$options[] = array(
'desc' => __('- 如果网站根目录下已经有 robots.txt 文件,下面的配置不会生效', 'kratos'),
'type' => 'info',
);
$options[] = array(
'desc' => __('- 点击 ', 'kratos') . $seorobots . __(' 查看配置是否生效,如果网站开启了 CDN,可能需要刷新缓存才会生效', 'kratos'),
'type' => 'info',
);
$options[] = array(
'id' => 'seo_robots',
'std' => getrobots(),
'type' => 'textarea',
);
/* ══════════════════════════════════════════════════════════
* 九、邮件通知 —— SMTP 与评论提醒
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('邮件通知', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('SMTP 服务', 'kratos'),
'desc' => __('用第三方邮箱发信。不开启时走服务器本地发信,很多主机上会被判定为垃圾邮件。', 'kratos'),
'id' => 'm_smtp',
'type' => 'checkbox',
);
$options[] = array(
'name' => __('邮件服务器', 'kratos'),
'desc' => __('填写发件服务器地址', 'kratos'),
'id' => 'm_host',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('服务器端口', 'kratos'),
'desc' => __('填写发件服务器端口', 'kratos'),
'id' => 'm_port',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('授权方式', 'kratos'),
'desc' => __('填写登录鉴权的方式,ssl 或 tls', 'kratos'),
'id' => 'm_sec',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('邮箱帐号', 'kratos'),
'desc' => __('填写邮箱账号', 'kratos'),
'id' => 'm_username',
'class' => 'hidden',
'type' => 'text',
);
$options[] = array(
'name' => __('邮箱密码', 'kratos'),
'desc' => __('填写邮箱密码或授权码', 'kratos'),
'id' => 'm_passwd',
'class' => 'hidden',
'type' => 'password',
);
$options[] = array(
'id' => 'm_sendmail',
'class' => 'hidden',
'type' => 'sendmail',
);
/* ══════════════════════════════════════════════════════════
* 十、自定义代码 —— 兜底用,放最后
* ══════════════════════════════════════════════════════════ */
$options[] = array(
'name' => __('自定义代码', 'kratos'),
'type' => 'heading',
);
$options[] = array(
'name' => __('自定义 CSS', 'kratos'),
'desc' => __('附加样式,在所有主题样式之后加载。保存后立即生效,随主题升级保留。', 'kratos'),
'id' => 'g_custom_css',
'std' => yang_opt_default_custom_css(),
'type' => 'code',
'settings' => array('rows' => 14),
);
$options[] = array(
'name' => __('自定义 JS', 'kratos'),
'desc' => __('附加脚本,在页面底部加载,不需要写 &lt;script&gt; 标签。', 'kratos'),
'id' => 'g_custom_js',
'std' => '',
'type' => 'code',
'settings' => array('rows' => 14),
);
return $options;
}