
如何用React.js创建一个无头的WordPress网站
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"; } }