get_comment_id_fields

函式
get_comment_id_fields ( $post_id = 0 )
引數
  • (int) $post_id Optional. Post ID. Defaults to the current post ID.
    Required:
返回值
  • (string) Hidden input HTML for replying to comments.
定義位置
相關方法
comment_id_fieldsget_comment_idget_comment_guidget_comment_dateget_comment_time
引入
3.0.0
棄用
-

get_comment_id_fields – 這個函式返回包含評論資訊的隱藏表單欄位,包括評論ID和安全nonce。它通常用在評論表單中。它把評論ID作為一個引數。

檢索用於回覆評論的隱藏輸入HTML。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_comment_id_fields( $post_id = 0 ) {
if ( empty( $post_id ) ) {
$post_id = get_the_ID();
}
$reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;
$result = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />n";
$result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />n";
/**
* Filters the returned comment ID fields.
*
* @since 3.0.0
*
* @param string $result The HTML-formatted hidden ID field comment elements.
* @param int $post_id The post ID.
* @param int $reply_to_id The ID of the comment being replied to.
*/
return apply_filters( 'comment_id_fields', $result, $post_id, $reply_to_id );
}
function get_comment_id_fields( $post_id = 0 ) { if ( empty( $post_id ) ) { $post_id = get_the_ID(); } $reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; $result = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />n"; $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />n"; /** * Filters the returned comment ID fields. * * @since 3.0.0 * * @param string $result The HTML-formatted hidden ID field comment elements. * @param int $post_id The post ID. * @param int $reply_to_id The ID of the comment being replied to. */ return apply_filters( 'comment_id_fields', $result, $post_id, $reply_to_id ); }
function get_comment_id_fields( $post_id = 0 ) {
	if ( empty( $post_id ) ) {
		$post_id = get_the_ID();
	}

	$reply_to_id = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0;
	$result      = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />n";
	$result     .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />n";

	/**
	 * Filters the returned comment ID fields.
	 *
	 * @since 3.0.0
	 *
	 * @param string $result      The HTML-formatted hidden ID field comment elements.
	 * @param int    $post_id     The post ID.
	 * @param int    $reply_to_id The ID of the comment being replied to.
	 */
	return apply_filters( 'comment_id_fields', $result, $post_id, $reply_to_id );
}

常見問題

FAQs
檢視更多 >