三项功能:
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(真实文章渲染目录 + 真实评论数据渲染)。
69 lines
2.5 KiB
PHP
69 lines
2.5 KiB
PHP
<?php
|
||
/**
|
||
* 模板函数
|
||
* @author Yongquan Yang <yangyq.net>
|
||
* @license MIT License
|
||
* @version 2020.03.17
|
||
*/
|
||
|
||
define('THEME_VERSION', wp_get_theme()->get('Version'));
|
||
|
||
// 主题配置
|
||
require get_template_directory() . '/inc/options-framework/autoload.php';
|
||
|
||
// 自定义代码(CSS / JS,存选项表而非主题目录)
|
||
require get_template_directory() . '/inc/theme-custom-code.php';
|
||
|
||
// 更新配置
|
||
require get_template_directory() . '/inc/update-checker/autoload.php';
|
||
|
||
// 核心配置
|
||
require get_template_directory() . '/inc/theme-core.php';
|
||
|
||
// 图片类选项的默认值(Logo/favicon/404/分享图… 空值时落到包内默认图)。
|
||
// 必须排在 theme-core.php 之后:它要用 ASSET_PATH 与 kratos_option。
|
||
require get_template_directory() . '/inc/theme-option-defaults.php';
|
||
|
||
// 站点配置
|
||
require get_template_directory() . '/inc/theme-setting.php';
|
||
|
||
// 纪念日自动哀悼(按日期判断,需在 theme-setting 之后,
|
||
// 因为它用到 kratos_option)
|
||
require get_template_directory() . '/inc/theme-mourning.php';
|
||
|
||
// 哀悼说明页(固定路径 /memory,由主题判定路由,不写数据库)
|
||
require get_template_directory() . '/inc/theme-mourning-page.php';
|
||
|
||
// 文章配置
|
||
require get_template_directory() . '/inc/theme-article.php';
|
||
|
||
// 评论区(统一渲染 + AJAX + 评论通知)。
|
||
// 必须在 theme-article.php 之后:后者不再定义评论函数,
|
||
// 但评论模板 comments.php 里引用的 comment_callbacks 由本文件提供。
|
||
// 也必须早于 theme-mail.php(评论通知要调 yang_mail_render)。
|
||
require get_template_directory() . '/inc/theme-comments.php';
|
||
|
||
// 小工具配置
|
||
require get_template_directory() . '/inc/theme-widgets.php';
|
||
|
||
// 文章增强
|
||
require get_template_directory() . '/inc/theme-shortcode.php';
|
||
|
||
// 文章目录([TOC] 短代码)
|
||
require get_template_directory() . '/inc/theme-toc.php';
|
||
|
||
// 添加导航目录
|
||
require get_template_directory() . '/inc/theme-navwalker.php';
|
||
|
||
// 对象存储配置
|
||
require get_template_directory() . '/inc/theme-dogecloud.php';
|
||
|
||
// 邮件模板:必须先于 theme-mail.php 加载,
|
||
// 因为后者在发信时会调用 yang_mail_render()
|
||
require get_template_directory() . '/inc/theme-mail-template.php';
|
||
|
||
// 邮件治理:统一接管发信通道、去重、关掉重复通知
|
||
require get_template_directory() . '/inc/theme-mail.php';
|
||
|
||
// SMTP 配置(连通性相关,实际接管在 theme-mail.php)
|
||
require get_template_directory() . '/inc/theme-smtp.php'; |