Answer the question
In order to leave comments, you need to log in
In the wordpress blog, the customization of the commenting form was applied, in woocommerce it is not, how to apply?
I just want to know if this is normal or if something is wrong with me. In essence, is it the same form of commenting in just WordPress and in woocommerce?
I found this customization method on the Internet. I don't know why fields are split into two separate functions, inputs
and textarea seem to be the same inside, but separately they work, and if you combine two functions into one, then only textarea is customized. The same is true if you overwrite comment_form_default_fields with woocommerce_product_review_comment_form_args. Textarea is applied, but inputs are not. Why are these methods wrong? I want to sort it out.
function placeholder_author_email_url_form_fields($fields) {
$replace_author = __('Your Name', 'themename');
$replace_email = __('Your Email', 'themename');
$replace_url = __('Your Website', 'themename');
$fields['author'] = '<div class="comment-form-author">' . '<label for="author">' . __( 'Name', 'themename' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
'<input id="author" name="author" type="text" placeholder="'.$replace_author.'" value="' . esc_attr( $commenter['comment_author'] ) . '" size="20"' . $aria_req . ' /></div>';
$fields['email'] = '<div class="comment-form-email"><label for="email">' . __( 'Email', 'themename' ) . '</label> ' .
( $req ? '<span class="required">*</span>' : '' ) .
'<input id="email" name="email" type="text" placeholder="'.$replace_email.'" value="' . esc_attr( $commenter['comment_author_email'] ) .
'" size="30"' . $aria_req . ' /></div>';
$fields['url'] = '<div class="comment-form-url"><label for="url">' . __( 'Website', 'themename' ) . '</label>' .
'<input id="url" name="url" type="text" placeholder="'.$replace_url.'" value="' . esc_attr( $commenter['comment_author_url'] ) .
'" size="30" /></div>';
return $fields;
}
add_filter('comment_form_default_fields','placeholder_author_email_url_form_fields');
/**
* Comment Form Placeholder Comment Field
*/
function placeholder_comment_form_field($fields) {
$replace_comment = __('Your Comment', 'themename');
$fields['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'themename' ) .
'</label><textarea id="comment" name="comment" cols="45" rows="8" placeholder="'.$replace_comment.'" aria-required="true"></textarea></p>';
return $fields;
}
add_filter( 'comment_form_defaults', 'placeholder_comment_form_field' );
/* Меняет текст чекбокса GDPR */
function comment_form_change_cookies_consent( $fields ) {
$commenter = wp_get_current_commenter();
$consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
$fields['cookies'] = '<div class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
'<label for="wp-comment-cookies-consent">Сохранить моё имя и email в этом браузере для последующих моих комментариев.</label></div>';
return $fields;
}
add_filter( 'comment_form_default_fields', 'comment_form_change_cookies_consent' );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question