diff --git a/inc/custom-comments.php b/inc/custom-comments.php index cf38f26..6292a74 100644 --- a/inc/custom-comments.php +++ b/inc/custom-comments.php @@ -8,61 +8,82 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; -// Comments form. +// Add Bootstrap classes to comment form fields. add_filter( 'comment_form_default_fields', 'understrap_bootstrap_comment_form_fields' ); -/** - * Creates the comments form. - * - * @param string $fields Form fields. - * - * @return array - */ - if ( ! function_exists( 'understrap_bootstrap_comment_form_fields' ) ) { - + /** + * Add Bootstrap classes to WP's comment form default fields. + * + * @param array $fields { + * Default comment fields. + * + * @type string $author Comment author field HTML. + * @type string $email Comment author email field HTML. + * @type string $url Comment author URL field HTML. + * @type string $cookies Comment cookie opt-in field HTML. + * } + * + * @return array + */ function understrap_bootstrap_comment_form_fields( $fields ) { - $commenter = wp_get_current_commenter(); - $req = get_option( 'require_name_email' ); - $aria_req = ( $req ? " aria-required='true'" : '' ); - $html5 = current_theme_supports( 'html5', 'comment-form' ) ? 1 : 0; - $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; - $fields = array( - 'author' => '
', - 'email' => ''' => '', ); + if ( isset( $fields['author'] ) ) { + $fields['author'] = strtr( $fields['author'], $replace ); + } + if ( isset( $fields['email'] ) ) { + $fields['email'] = strtr( $fields['email'], $replace ); + } + if ( isset( $fields['url'] ) ) { + $fields['url'] = strtr( $fields['url'], $replace ); + } + + $replace = array( + '
' '