
WordPress钩子详解:如何使用动作、过滤器和自定义钩子
comment_form_title ( $no_reply_text = false, $reply_text = false, $link_to_parent = true )
comment_form_title: 这个函数生成评论表格的标题。默认情况下,它为文章显示文本”留下回复”,为页面显示文本”留下评论”。
根据评论回复状态显示文本。
只影响到禁用了JavaScript的用户。
function comment_form_title( $no_reply_text = false, $reply_text = false, $link_to_parent = true ) { global $comment; if ( false === $no_reply_text ) { $no_reply_text = __( 'Leave a Reply' ); } if ( false === $reply_text ) { /* translators: %s: Author of the comment being replied to. */ $reply_text = __( 'Leave a Reply to %s' ); } $reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; if ( 0 == $reply_to_id ) { echo $no_reply_text; } else { // Sets the global so that template tags can be used in the comment form. $comment = get_comment( $reply_to_id ); if ( $link_to_parent ) { $author = '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>'; } else { $author = get_comment_author( $comment ); } printf( $reply_text, $author ); } }