` 里直接放
* `wp_list_comments()` 输出的 `
`,标签层级非法。浏览器会
* 自行"修复"结构,而嵌套回复(``)在这种
* 被修复过的树里容易错位 —— 这是"评论看起来乱"的一个真实来源。
*
* 2. **回复状态条**。点「回复」时除了把表单挪过去,还在表单上方
* 显示「正在回复 @某人 / 取消」。旧实现只有表单被挪动这一条线索,
* 用户在长评论区里挪动后常常不知道自己到底在回复谁。
*
* 3. **表单加 nonce**。AJAX 提交走 nonce 校验,没有它任何第三方
* 页面都能借访客的浏览器刷评论。
*
* 4. **提交按钮的禁用态由 JS 控制**,模板里给出 `.is-loading` 的样式钩子。
*
* @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', 'style' => 'ol', 'max_depth' => $yang_threaded ? $yang_max_depth : 1, 'avatar_size' => 48, 'per_page' => $yang_paged ? $yang_per_page : 0, 'page' => 1, )); ?>
$yang_per_page; ?>