这段教程代码的作用就是在评论回复某条评论时,自动在评论内容前方加上@xxx
的效果
function ludou_comment_add_at( $comment_text, $comment = '') {
if( $comment->comment_parent > 0) {
$comment_text = '@'.get_comment_author( $comment->comment_parent ) . ' ' . $comment_text;
}
return $comment_text;
}
add_filter( 'comment_text' , 'ludou_comment_add_at', 20, 2);
function recover_comment_fields($comment_fields){
$comment = array_shift($comment_fields);
$comment_fields = array_merge($comment_fields ,array('comment' => $comment));
return $comment_fields;
}
add_filter('comment_form_fields','recover_comment_fields');
代码来自露蔸博客。