typecho 在评论时默认是没有 @ 评论人的功能,可以用代码加一下。

functions.php 中:

/*
* 评论回复时 @ 评论人
*/
function get_comment_at($coid)
{
    $db   = Typecho_Db::get();
    $prow = $db->fetchRow($db->select('parent,status')->from('table.comments')
        ->where('coid = ?', $coid));
    $mail = "";
    $parent = @$prow['parent'];
    if ($parent != "0") {
        $arow = $db->fetchRow($db->select('author,status,mail')->from('table.comments')
            ->where('coid = ?', $parent));
        @$author = @$arow['author'];
        $mail = @$arow['mail'];
        if(@$author && $arow['status'] == "approved"){
            if (@$prow['status'] == "waiting"){
                echo '<p class="commentReview">(评论审核中))</p>';
            }
            echo '<a href="#comment-' . $parent . '">@' . $author . '</a>';
        }else{
            if (@$prow['status'] == "waiting"){
                echo '<p class="commentReview">(评论审核中))</p>';
            }else{
                echo '';
            }
        }

    } else {
        if (@$prow['status'] == "waiting"){
            echo '<p class="commentReview">(评论审核中))</p>';
        }else{
            echo '';
        }
    }
}

然后在 comments.php 中输出评论内容代码的前面加上:

<?php $parentMail = get_comment_at($comments->coid)?><?php echo $parentMail;?>

▼代码所示 1654569311759.png

▼效果图 1654569512094.png


我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=17ctk6evsjk5b