Skip to content
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

Closed
kiopc opened this issue May 26, 2020 · 2 comments
Closed

建议优化回复评论关系 #223

kiopc opened this issue May 26, 2020 · 2 comments

Comments

@kiopc
Copy link

kiopc commented May 26, 2020

问题描述
建议优化评论回复关系

环境信息
无关环境信息

复现步奏
个人使用的评论回复关系代码,添加到了functions.php
/**

  • 获取评论信息
  • @10:优先级
  • @3:自定义函数能接受几个参数
    */
    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');
}

@seatonjiang
Copy link
Owner

image
增强了评论关系

@kiopc
Copy link
Author

kiopc commented Jun 2, 2020

image
增强了评论关系

辛苦大佬

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants