Passed
Push — master ( 86dfed...3aa001 )
by Warwick
05:45
created

comments.php (23 issues)

1
<?php
2
/**
3
 * The template for displaying Comments.
4
 *
5
 * @package lsx
6
 */
7
8
if ( post_password_required() ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
9
	return;
10
}
11
12
$commenter = wp_get_current_commenter();
13
$req       = get_option( 'require_name_email' );
14
$aria_req  = ( $req ? " aria-required='true'" : '' );
15
$html_req  = ( $req ? " required='required'" : '' );
16
17
$comment_form_args = array(
18
	'comment_field' => '<p class="comment-form-comment"><textarea placeholder="' . esc_html__( 'Comment', 'lsx' ) . '" id="comment" class="form-control" name="comment" cols="45" rows="8"' . $aria_req . $html_req . '></textarea></p>',
19
20
	'fields'        => array(
21
		'author' => '<p class="comment-form-author"><label for="author">' . esc_html__( 'Name', 'lsx' ) . '</label> ' .
22
			( $req ? '<span class="required">*</span>' : '' ) .
23
			'<input class="form-control" placeholder="' . esc_html__( 'Name', 'lsx' ) . '" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . '></p>',
24
25
		'email'  => '<p class="comment-form-email"><label for="email">' . esc_html__( 'Email', 'lsx' ) . '</label> ' .
26
			( $req ? '<span class="required">*</span>' : '' ) .
27
			'<input class="form-control" placeholder="' . esc_html__( 'Email', 'lsx' ) . '" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . $html_req . '></p>',
28
29
		'url'    => '<p class="comment-form-url"><label for="url">' . esc_html__( 'Website', 'lsx' ) . '</label>' .
30
			'<input class="form-control" placeholder="' . esc_html__( 'Website', 'lsx' ) . '" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30"></p>',
31
	),
32
);
33
34
comment_form( $comment_form_args );
35
36
if ( have_comments() ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
Blank line found at start of control structure
Loading history...
37
38
	<?php lsx_comments_before(); ?>
39
40
	<section id="comments">
41
		<h3>
42
			<?php
43
				$comments_number = get_comments_number();
44
45
			if ( '1' === $comments_number ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
46
				printf(
47
					/* Translators: %s: post title */
48
					esc_html_x( 'One Response to &ldquo;%s&rdquo;', 'comments.php', 'lsx' ),
49
					get_the_title()
0 ignored issues
show
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'get_the_title'.
Loading history...
50
				);
51
			} else {
52
				printf(
53
					esc_html(
54
						/* Translators: 1: number of comments, 2: post title */
55
						_nx(
56
							'%1$s Response to &ldquo;%2$s&rdquo;',
57
							'%1$s Responses to &ldquo;%2$s&rdquo;',
58
							$comments_number,
0 ignored issues
show
It seems like $comments_number can also be of type string; however, parameter $number of _nx() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

58
							/** @scrutinizer ignore-type */ $comments_number,
Loading history...
59
							'comments.php',
60
							'lsx'
61
						)
62
					),
63
					esc_html( number_format_i18n( $comments_number ) ),
0 ignored issues
show
It seems like $comments_number can also be of type string; however, parameter $number of number_format_i18n() does only seem to accept double, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

63
					esc_html( number_format_i18n( /** @scrutinizer ignore-type */ $comments_number ) ),
Loading history...
64
					get_the_title()
0 ignored issues
show
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'get_the_title'.
Loading history...
65
				);
66
			}
67
			?>
68
		</h3>
69
70
		<ol class="media-list">
71
			<?php
72
				wp_list_comments(
73
					array(
74
						'walker' => new LSX_Walker_Comment(),
75
					)
76
				);
77
			?>
78
		</ol>
79
80
		<?php
81
		$comment_pages_count = get_comment_pages_count();
82
		if ( $comment_pages_count > 1 && get_option( 'page_comments' ) ) :
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
83
			?>
84
			<nav>
85
				<ul class="pager">
86
					<?php if ( get_previous_comments_link() ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
87
						<li class="previous"><?php previous_comments_link( esc_html__( '&larr; Older comments', 'lsx' ) ); ?></li>
88
					<?php endif; ?>
89
90
					<?php if ( get_next_comments_link() ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
91
						<li class="next"><?php next_comments_link( esc_html__( 'Newer comments &rarr;', 'lsx' ) ); ?></li>
92
					<?php endif; ?>
93
				</ul>
94
			</nav>
95
		<?php endif; ?>
96
97
		<?php if ( ! comments_open() && ! is_page() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
98
			<div class="alert alert-warning">
99
				<?php esc_html_e( 'Comments are closed.', 'lsx' ); ?>
100
			</div>
101
		<?php endif; ?>
102
	</section><!-- /#comments -->
103
104
	<?php lsx_comments_after(); ?>
105
106
<?php endif; ?>
107
108
<?php if ( ! have_comments() && ! comments_open() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
Blank line found at start of control structure
Loading history...
109
110
	<section id="comments">
111
		<div class="alert alert-warning">
112
			<?php esc_html_e( 'Comments are closed.', 'lsx' ); ?>
113
		</div>
114
	</section><!-- /#comments -->
115
116
	<?php lsx_comments_after(); ?>
117
118
	<?php
119
	endif;
0 ignored issues
show
Closing brace indented incorrectly; expected 0 spaces, found 4
Loading history...
120
?>
121