wp_comment_form_unfiltered_html_nonce

Display form token for unfiltered comments.

Description

wp_comment_form_unfiltered_html_nonce(); 

Will only display nonce token if the current user has permissions for unfiltered html. Won't display the token for other users.

The function was backported to 2.0.10 and was added to versions 2.1.3 and above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.

Backported to 2.0.10.


Usage

  1. if ( !function_exists( 'wp_comment_form_unfiltered_html_nonce' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_comment_form_unfiltered_html_nonce(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment-template.php  
  1. function wp_comment_form_unfiltered_html_nonce() { 
  2. $post = get_post(); 
  3. $post_id = $post ? $post->ID : 0; 
  4.  
  5. if ( current_user_can( 'unfiltered_html' ) ) { 
  6. wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); 
  7. echo "<script>(function() {if(window===window.parent) {document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n";