Open joethseo opened 1 year ago
Yes, it is very important. I also do not know what styling options for required, error and success do ? WordPress leads error to separate wp_die page and makes all this useless.
One Youtube video tutorial how to style comments and comment form would be very nice. Seems as it is not finished yet.
While it does not solve original issue it helped me solve redirect to stupid WordPress error page. And it marks required fields with color.
https://wordpress.org/plugins/enhanced-comment-validation/
This plugin and following helped me achieve most what I needed:
Breakdance Code block.
#commentform #submit[disabled] {
background-color: #ddd;
}
.oxy-comment-form label {
display: block;
}
.comment-form-cookies-consent {
display: flex;
}
.breakdance-form .comment-form-cookies-consent label {
line-height: 1.1;
font-weight: normal;
}
(function($) {
$('#wp-comment-cookies-consent').change(function () {
$('#commentform #submit').prop("disabled", !this.checked);
}).change()
})(jQuery);
Custom snippet (not in the Code block):
add_filter( 'comment_form_default_fields', 'tu_comment_form_change_cookies_consent' );
function tu_comment_form_change_cookies_consent( $fields ) {
$commenter = wp_get_current_commenter();
// $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"';
$fields['cookies'] = '<div class="breakdance-form-field"><div class="breakdance-form-checkbox"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"' . $consent . ' />' .
'<label class="breakdance-form-checkbox__text" for="wp-comment-cookies-consent">Save my name, email, and website in this browser for the next time I comment. & Personal information in database for statistical purposes.</label></div></div>';
return $fields;
}
Here is it how you add required asterix. Have to find out how to show it for textarea field. (Works with placeholders too.)
/**
* Change comment form textarea to use placeholder
*
* @since 1.0.0
* @param array $args
* @return array
*/
function ea_comment_textarea_placeholder( $args ) {
$args['comment_field'] = str_replace( 'textarea', 'textarea placeholder="comment"', $args['comment_field'] );
return $args;
}
add_filter( 'comment_form_defaults', 'ea_comment_textarea_placeholder' );
/**
* Comment Form Fields Placeholder
*
*/
function be_comment_form_fields( $fields ) {
foreach( $fields as &$field ) {
$field = str_replace( 'id="author"', 'id="author" placeholder="Name*"', $field );
$field = str_replace( 'id="email"', 'id="email" placeholder="E-Mail*"', $field );
// $field = str_replace( 'id="url"', 'id="url" placeholder="website"', $field );
}
return $fields;
}
add_filter( 'comment_form_default_fields', 'be_comment_form_fields' );
comment_field is not inside "comment_form_default_fields", but simple snippet under works well. (Tested with "Apply the_content filter to Breakdance content" on and off.)
function replace_text_wps($text){
$replace = array(
// 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
'class="breakdance-form-field__input"' => 'class="breakdance-form-field__input" placeholder="Comment*"'
);
$text = str_replace(array_keys($replace), $replace, $text);
return $text;
}
add_filter('the_content', 'replace_text_wps');
See here: