在评论部分更改验证码的位置
Change positionining of captcha in comment section
我想更改评论元素的呈现顺序。我正在使用来自 wordpress 的 'Advanced noCaptcha & invisible captcha' 插件。验证码呈现在输入字段和文本字段之间(见图)。我希望它呈现在文本区域字段和提交按钮之间。
关于如何实现这一目标的任何想法?
干杯。
这是我在 comments.php 中找到的内容:
$fields = [];
$fields['author'] = '<label id="comment-input"><input /*some input stuff*/ placeholder="NAME*"/>';
$fields['email'] = '<input /*some input stuff*/ placeholder="IHRE E-MAIL ADRESSE * (wird nicht angezeigt)"/>';
$fields['url'] = '<input /*some input stuff*/ placeholder="Webseite" />';
$comments_args = [
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
'comment_field' => '<div id="comment-textarea"><label class="screen-reader-text" for="comment">' . esc_attr__( 'Comment', 'Avada' ) . '</label><textarea /*some input stuff*/" placeholder="KOMMENTAR VERFASSEN..."></textarea></div>',
'title_reply' => esc_html__( 'Leave A Comment', 'Avada' ),
'title_reply_to' => esc_html__( 'Leave A Comment', 'Avada' ),
//some more comment args
];
comment_form( $comments_args );
我想出了一个解决方法。给出一些上下文:验证码似乎附加到评论部分内的最后一个元素,同时忽略文本区域评论框。
有一个 WP-filter 可用于重新排列不同的字段。我根据需要排列了字段,然后在末尾添加了一个额外的空白字段(占位符),以便验证码附加到它。这似乎可以解决问题。如果没有占位符,即使 'comment' 字段在最后,它也不起作用。
这是我在 functions.php:
中使用的代码
function change_comment_fields_order($fields)
{
$comment_field = $fields['comment'];
$author_field = $fields['author'];
$email_field = $fields['email'];
$url_field = $fields['url'];
//unset
unset($fields['comment']);
unset($fields['author']);
unset($fields['email']);
unset($fields['url']);
// the order of fields is the order below, change it as needed:
$fields['author'] = $author_field;
$fields['email'] = $email_field;
$fields['url'] = $url_field;
$fields['comment'] = $comment_field;
//placeholder is a little hack that prevents the recaptcha thingy from being rendered in between the comment and the url fileds
$fields['placeholder'] = "";
// done ordering, now return the fields:
return $fields;
}
add_filter('comment_form_fields', 'change_comment_fields_order');
我想更改评论元素的呈现顺序。我正在使用来自 wordpress 的 'Advanced noCaptcha & invisible captcha' 插件。验证码呈现在输入字段和文本字段之间(见图)。我希望它呈现在文本区域字段和提交按钮之间。
关于如何实现这一目标的任何想法?
干杯。
这是我在 comments.php 中找到的内容:
$fields = [];
$fields['author'] = '<label id="comment-input"><input /*some input stuff*/ placeholder="NAME*"/>';
$fields['email'] = '<input /*some input stuff*/ placeholder="IHRE E-MAIL ADRESSE * (wird nicht angezeigt)"/>';
$fields['url'] = '<input /*some input stuff*/ placeholder="Webseite" />';
$comments_args = [
'fields' => apply_filters( 'comment_form_default_fields', $fields ),
'comment_field' => '<div id="comment-textarea"><label class="screen-reader-text" for="comment">' . esc_attr__( 'Comment', 'Avada' ) . '</label><textarea /*some input stuff*/" placeholder="KOMMENTAR VERFASSEN..."></textarea></div>',
'title_reply' => esc_html__( 'Leave A Comment', 'Avada' ),
'title_reply_to' => esc_html__( 'Leave A Comment', 'Avada' ),
//some more comment args
];
comment_form( $comments_args );
我想出了一个解决方法。给出一些上下文:验证码似乎附加到评论部分内的最后一个元素,同时忽略文本区域评论框。
有一个 WP-filter 可用于重新排列不同的字段。我根据需要排列了字段,然后在末尾添加了一个额外的空白字段(占位符),以便验证码附加到它。这似乎可以解决问题。如果没有占位符,即使 'comment' 字段在最后,它也不起作用。
这是我在 functions.php:
function change_comment_fields_order($fields)
{
$comment_field = $fields['comment'];
$author_field = $fields['author'];
$email_field = $fields['email'];
$url_field = $fields['url'];
//unset
unset($fields['comment']);
unset($fields['author']);
unset($fields['email']);
unset($fields['url']);
// the order of fields is the order below, change it as needed:
$fields['author'] = $author_field;
$fields['email'] = $email_field;
$fields['url'] = $url_field;
$fields['comment'] = $comment_field;
//placeholder is a little hack that prevents the recaptcha thingy from being rendered in between the comment and the url fileds
$fields['placeholder'] = "";
// done ordering, now return the fields:
return $fields;
}
add_filter('comment_form_fields', 'change_comment_fields_order');