` 里直接放
* `wp_list_comments()` 输出的 `
`,标签层级非法。浏览器会
* 自行"修复"结构,而嵌套回复(``)在这种
* 被修复过的树里容易错位 —— 这是"评论看起来乱"的一个真实来源。
*
* 2. **回复状态条**。点「回复」时除了把表单挪过去,还在表单上方
* 显示「正在回复 @某人 / 取消」。旧实现只有表单被挪动这一条线索,
* 用户在长评论区里挪动后常常不知道自己到底在回复谁。
*
* 3. **表单加 nonce**。AJAX 提交走 nonce 校验,没有它任何第三方
* 页面都能借访客的浏览器刷评论。
*
* 4. **提交按钮的禁用态由 JS 控制**,模板里给出 `.is-loading` 的样式钩子。
*
* ── 3.2.19 修的两个结构问题 ──────────────────────────────────
* 5. **取数不再交给 `wp_list_comments()` 推导**。3.2.18 传了
* `page=1` / `per_page=10`,而核心那段"独立查询"分支在内层
* 条件不成立时**不会给 `$_comments` 赋值**(注释说会回退到
* `$wp_query->comments`,但代码里没有这个回退),结果
* `paged_walk(null, ...)` 输出空串 —— 评论一条都不显示。
* 现在由 `yang_comment_page()` 取好、当第二个参数传进去。
*
* 6. **子评论容器改成 `yang-children`**(见 `Yang_Walker_Comment`)。
* 核心 `start_lvl()` 固定输出 `class="children"`,而样式表里
* 几十条规则全按 `.yang-children` 写,类名对不上就全部失效。
*
* @author Yongquan Yang
* @license MIT License
*/
if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME'])) {
die();
}
require get_template_directory() . '/pages/page-smilies.php';
$yang_post_id = get_the_ID();
$yang_comment_count = (int) get_comments_number($yang_post_id);
$yang_max_depth = (int) get_option('thread_comments_depth', 5);
if ($yang_max_depth <= 0) {
$yang_max_depth = 5;
}
$yang_threaded = (bool) get_option('thread_comments');
$yang_has_comments = ($yang_comment_count > 0);
/* 评论是否分页:分页时首屏只给「加载更多」,不一次性铺全部 */
$yang_paged = (bool) get_option('page_comments');
$yang_per_page = (int) get_option('comments_per_page', 20);
if ($yang_per_page <= 0) {
$yang_per_page = 20;
}
?>
0) { printf( /* translators: %s: 评论条数 */ esc_html__('评论(%s)', 'kratos'), esc_html(number_format_i18n($yang_comment_count)) ); } else { esc_html_e('评论', 'kratos'); } ?>
。 */ ?>>
'comment', 'callback' => 'comment_callbacks', 'walker' => new Yang_Walker_Comment(), 'style' => 'ol', 'max_depth' => $yang_threaded ? $yang_max_depth : 1, 'avatar_size' => 48, 'per_page' => 0, 'page' => 0, ), $yang_page_comments); ?>
$yang_post_id, 'status' => 'approve', 'parent' => 0, 'count' => true, )); $yang_has_more = $yang_paged && $yang_top_count > $yang_per_page; ?>