diff --git a/comments.php b/comments.php index 21a8635..7742e3f 100644 --- a/comments.php +++ b/comments.php @@ -38,16 +38,18 @@ if ( post_password_required() ) { '' . get_the_title() . '' ); } else { - printf( // WPCS: XSS OK. - /* translators: 1: number of comments, 2: post title */ - esc_html( _nx( - '%1$s thought on “%2$s”', - '%1$s thoughts on “%2$s”', - $comments_number, - 'comments title', - 'understrap' - ) ), - number_format_i18n( $comments_number ), + printf( + esc_html( + /* translators: 1: number of comments, 2: post title */ + _nx( + '%1$s thought on “%2$s”', + '%1$s thoughts on “%2$s”', + $comments_number, + 'comments title', + 'understrap' + ) + ), + number_format_i18n( $comments_number ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped '' . get_the_title() . '' ); } @@ -55,7 +57,7 @@ if ( post_password_required() ) { - 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through. ?> + 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through. ?> - +
    @@ -90,7 +92,7 @@ if ( post_password_required() ) {
- 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through. ?> + 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through. ?> - + - - - - -

- - + diff --git a/inc/custom-comments.php b/inc/custom-comments.php index cf38f26..faeb2a3 100644 --- a/inc/custom-comments.php +++ b/inc/custom-comments.php @@ -8,61 +8,99 @@ // 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' => '
' . - '
', - 'url' => '
' . - '
', - 'cookies' => '', + + $replace = array( + '

'' => '', ); + 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( + '

' '

- - -
'; - $args['class_submit'] = 'btn btn-secondary'; // since WP 4.1. + $replace = array( + '

'