comment_form_title

函式
comment_form_title ( $no_reply_text = false, $reply_text = false, $link_to_parent = true )
引數
  • (string|false) $no_reply_text Optional. Text to display when not replying to a comment. Default false.
    Required:
    Default: false
  • (string|false) $reply_text Optional. Text to display when replying to a comment. Default false. Accepts "%s" for the author of the comment being replied to.
    Required:
    Default: false
  • (bool) $link_to_parent Optional. Boolean to control making the author's name a link to their comment. Default true.
    Required:
    Default: true
定義位置
相關方法
comment_formcomment_timecomment_author_ipcomment_datecomment_footer_die
引入
2.7.0
棄用
-

comment_form_title: 這個函式生成評論表格的標題。預設情況下,它為文章顯示文字”留下回復”,為頁面顯示文字”留下評論”。

根據評論回覆狀態顯示文字。

隻影響到禁用了JavaScript的使用者。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
}
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 ); } }
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 );
	}
}

常見問題

FAQs
檢視更多 >