-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
建议优化回复评论关系 #223
Comments
seatonjiang
added a commit
that referenced
this issue
May 30, 2020
seatonjiang
added a commit
that referenced
this issue
Jun 6, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题描述
建议优化评论回复关系
环境信息
无关环境信息
复现步奏
个人使用的评论回复关系代码,添加到了functions.php
/**
*/
function mini_get_qa($out,$author,$comment_id){
$comment = get_comment($comment_id);
// 如果没有父级评论,则正常返回,因为没有回复关系
if ( empty( $comment->comment_parent ) ){
return $out;
}
// 如果有父级评论,则添加回复关系
// 获取父(原)评论
$parent = get_comment($comment->comment_parent);
// 获取父(原)评论作者
$pauthor = get_comment_author($parent);
//构建回复关系
$pcid = '#content-' . $parent->comment_ID;
$new = $out . '回复' . "{$pauthor}";
// 返回修改后的评论
return $new;
}
add_filter('get_comment_author_link','mini_get_qa', 10, 3);
// 需要在后台设置 -> 讨论 -> 其他评论设置 -> 启用评论嵌套
// 引入回复时,评论框跟随 -> mini_get_qa()
if( is_singular() && comments_open() && get_option('thread_comments') ){
wp_enqueue_script('comment-reply');
}
The text was updated successfully, but these errors were encountered: