@@ -564,7 +564,7 @@ function get_comment_class( $css_class = '', $comment_id = null, $post = null )
564
564
++$ comment_alt ;
565
565
566
566
// Alt for top-level comments.
567
- if ( 1 == $ comment_depth ) {
567
+ if ( 1 === $ comment_depth ) {
568
568
if ( $ comment_thread_alt % 2 ) {
569
569
$ classes [] = 'thread-odd ' ;
570
570
$ classes [] = 'thread-alt ' ;
@@ -814,9 +814,9 @@ function get_comment_link( $comment = null, $args = array() ) {
814
814
815
815
$ cpage = $ args ['page ' ];
816
816
817
- if ( '' == $ cpage ) {
817
+ if ( '' === $ cpage ) {
818
818
if ( ! empty ( $ in_comment_loop ) ) {
819
- $ cpage = get_query_var ( 'cpage ' );
819
+ $ cpage = ( int ) get_query_var ( 'cpage ' );
820
820
} else {
821
821
// Requires a database hit, so we only do it when we can't figure out from context.
822
822
$ cpage = get_page_of_comment ( $ comment ->comment_ID , $ args );
@@ -1605,7 +1605,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
1605
1605
1606
1606
$ overridden_cpage = false ;
1607
1607
1608
- if ( '' == get_query_var ( 'cpage ' ) && $ wp_query ->max_num_comment_pages > 1 ) {
1608
+ if ( '' === get_query_var ( 'cpage ' ) && $ wp_query ->max_num_comment_pages > 1 ) {
1609
1609
set_query_var ( 'cpage ' , 'newest ' === get_option ( 'default_comments_page ' ) ? get_comment_pages_count () : 1 );
1610
1610
$ overridden_cpage = true ;
1611
1611
}
@@ -2291,13 +2291,13 @@ function wp_list_comments( $args = array(), $comments = null ) {
2291
2291
* perform a separate comment query and allow Walker_Comment to paginate.
2292
2292
*/
2293
2293
if ( $ parsed_args ['page ' ] || $ parsed_args ['per_page ' ] ) {
2294
- $ current_cpage = get_query_var ( 'cpage ' );
2294
+ $ current_cpage = ( int ) get_query_var ( 'cpage ' );
2295
2295
if ( ! $ current_cpage ) {
2296
2296
$ current_cpage = 'newest ' === get_option ( 'default_comments_page ' ) ? 1 : $ wp_query ->max_num_comment_pages ;
2297
2297
}
2298
2298
2299
- $ current_per_page = get_query_var ( 'comments_per_page ' );
2300
- if ( $ parsed_args ['page ' ] != $ current_cpage || $ parsed_args ['per_page ' ] != $ current_per_page ) {
2299
+ $ current_per_page = ( int ) get_query_var ( 'comments_per_page ' );
2300
+ if ( ( int ) $ parsed_args ['page ' ] !== $ current_cpage || ( int ) $ parsed_args ['per_page ' ] != = $ current_per_page ) {
2301
2301
$ comment_args = array (
2302
2302
'post_id ' => get_the_ID (),
2303
2303
'orderby ' => 'comment_date_gmt ' ,
@@ -2348,15 +2348,15 @@ function wp_list_comments( $args = array(), $comments = null ) {
2348
2348
2349
2349
if ( $ wp_query ->max_num_comment_pages ) {
2350
2350
$ default_comments_page = get_option ( 'default_comments_page ' );
2351
- $ cpage = get_query_var ( 'cpage ' );
2351
+ $ cpage = (int ) get_query_var ( 'cpage ' );
2352
+
2352
2353
if ( 'newest ' === $ default_comments_page ) {
2353
2354
$ parsed_args ['cpage ' ] = $ cpage ;
2354
-
2355
+ } elseif ( 1 === $ cpage ) {
2355
2356
/*
2356
- * When first page shows oldest comments, post permalink is the same as
2357
- * the comment permalink.
2358
- */
2359
- } elseif ( 1 == $ cpage ) {
2357
+ * When the first page shows the oldest comments,
2358
+ * post permalink is the same as the comment permalink.
2359
+ */
2360
2360
$ parsed_args ['cpage ' ] = '' ;
2361
2361
} else {
2362
2362
$ parsed_args ['cpage ' ] = $ cpage ;
@@ -2389,14 +2389,16 @@ function wp_list_comments( $args = array(), $comments = null ) {
2389
2389
if ( empty ( $ overridden_cpage ) ) {
2390
2390
$ parsed_args ['page ' ] = get_query_var ( 'cpage ' );
2391
2391
} else {
2392
- $ threaded = ( -1 != $ parsed_args ['max_depth ' ] );
2392
+ $ threaded = ( -1 !== ( int ) $ parsed_args ['max_depth ' ] );
2393
2393
$ parsed_args ['page ' ] = ( 'newest ' === get_option ( 'default_comments_page ' ) ) ? get_comment_pages_count ( $ _comments , $ parsed_args ['per_page ' ], $ threaded ) : 1 ;
2394
2394
set_query_var ( 'cpage ' , $ parsed_args ['page ' ] );
2395
2395
}
2396
2396
}
2397
+
2397
2398
// Validation check.
2398
- $ parsed_args ['page ' ] = (int ) $ parsed_args ['page ' ];
2399
- if ( 0 == $ parsed_args ['page ' ] && 0 != $ parsed_args ['per_page ' ] ) {
2399
+ $ parsed_args ['page ' ] = (int ) $ parsed_args ['page ' ];
2400
+ $ parsed_args ['per_page ' ] = (int ) $ parsed_args ['per_page ' ];
2401
+ if ( 0 === $ parsed_args ['page ' ] && 0 !== $ parsed_args ['per_page ' ] ) {
2400
2402
$ parsed_args ['page ' ] = 1 ;
2401
2403
}
2402
2404
0 commit comments