[摘要]
近期在回复博友评论时发现评论框不跟随,点击评论按钮页面刷新的情况,这个体验实在是很差。我记得这个问题很早之前就出现过,也记得处理了,不知道为啥又莫名其妙的出现了。
近期在回复博友评论时发现评论框不跟随,点击评论按钮页面刷新的情况,这个体验实在是很差。我记得这个问题很早之前就出现过,也记得处理了,不知道为啥又莫名其妙的出现了。
主要是WordPress官方修改了该函数的输出结构,去掉了一个绑定的点击事件
不管了本着面向百度开发的原则,找到了靠谱的代码
/**
* 修改评论回复按钮链接
*/
global $wp_version;
if (version_compare($wp_version, '5.1.1', '>=')) {
add_filter('comment_reply_link', 'theme_replace_comment_reply_link', 10, 4);
function theme_replace_comment_reply_link($link, $args, $comment, $post)
{
if (get_option('comment_registration') && !is_user_logged_in()) {
$link = sprintf(
'',
esc_url(wp_login_url(get_permalink())),
$args['login_text']
);
} else {
$onclick = sprintf(
'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
$args['add_below'],
$comment->comment_ID,
$args['respond_id'],
$post->ID
);
$link = sprintf(
"",
esc_url(add_query_arg('replytocom', $comment->comment_ID, get_permalink($post->ID))) . "#" . $args['respond_id'],
$onclick,
esc_attr(sprintf($args['reply_to_text'], $comment->comment_author)),
$args['reply_text']
);
}
return $link;
}
}
问题解决~~
本文最后更新于2021年10月11日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!





粤公网安备 44040402000065号
居然还反复?![[抠鼻]](https://www.yaxi.net/wp-content/themes/wing/img/smilies/kb.gif)
改好的效果呢?
@西枫里博客: 大佬