wp_comment_form_unfiltered_html_nonce

函式
wp_comment_form_unfiltered_html_nonce ( No parameters )

wp_comment_form_unfiltered_html_nonce: 這是一個動作鉤子,用來在評論表單中新增一個nonce,以防止惡意的輸入。它可以用來防止跨站請求偽造(CSRF)攻擊。

顯示未經過濾的評論的表單令牌。

只有噹噹前使用者有許可權使用未過濾的html時,才會顯示nonce令牌。不會為其他使用者顯示令牌。

該功能已被回傳到2.0.10版本,並被新增到2.1.3及以上版本。在2.0.10之前的2.0分支和2.1分支中,在2.1.3之前的版本中不存在。技術上是在2.2.0中新增的。

已回傳到2.0.10。

function wp_comment_form_unfiltered_html_nonce() {
	$post    = get_post();
	$post_id = $post ? $post->ID : 0;

	if ( current_user_can( 'unfiltered_html' ) ) {
		wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
		echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>n";
	}
}

常見問題

FAQs
檢視更多 >