根据评论回复状态显示文本。
原型
comment_form_title( string $noreplytext = false, string $replytext = false, string $linktoparent = true )
描述
仅影响禁用JavaScript的用户。
参数
$noreplytext
(string)
(Optional)
不回复评论时显示的文本。
$replytext
(string)
(Optional)
回复评论时要显示的文本。接受回复的评论的作者接受“%s”。
$linktoparent
(string)
(Optional)
布尔来控制使作者的名字成为他们评论的链接。
源文件
路径:wp-includes/comment-template.php
<?php
...
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
global $comment;
if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
$replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
if ( 0 == $replytoid )
echo $noreplytext;
else {
// Sets the global so that template tags can be used in the comment form.
$comment = get_comment($replytoid);
$author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment );
printf( $replytext, $author );
}
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/comment_form_title/