Ticket #31101: 31101.patch
File 31101.patch, 1.8 KB (added by , 10 years ago) |
---|
-
src/wp-includes/comment.php
1375 1375 1376 1376 $comtypewhere = ( 'all' != $args['type'] && isset($allowedtypes[$args['type']]) ) ? " AND comment_type = '" . $allowedtypes[$args['type']] . "'" : ''; 1377 1377 1378 // Count comments older than this one 1379 $oldercoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt < '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); 1378 // Determine proper date comparison operator based on comment order 1379 $comment_order = get_option('comment_order'); 1380 if ($comment_order == 'desc') { 1381 $date_compare = '>'; 1382 } else { 1383 $date_compare = '<'; 1384 } 1380 1385 1381 // No older comments? Then it's page #1. 1382 if ( 0 == $oldercoms ) 1386 // Count comments older/newer than this one. 1387 // If comment order is "desc" (newer at the top), find newer comments. 1388 // If comment order is "asc" (older at the top), find older comments. 1389 $foundcoms = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = 0 AND comment_approved = '1' AND comment_date_gmt " . $date_compare . " '%s'" . $comtypewhere, $comment->comment_post_ID, $comment->comment_date_gmt ) ); 1390 1391 // No older/newer comments? Then it's page #1. 1392 if ( 0 == $foundcoms ) 1383 1393 return 1; 1384 1394 1385 // Divide comments older than this one by comments per page to get this comment's page number1386 return ceil( ( $ oldercoms + 1 ) / $args['per_page'] );1395 // Divide comments older/newer than this one by comments per page to get this comment's page number 1396 return ceil( ( $foundcoms + 1 ) / $args['per_page'] ); 1387 1397 } 1388 1398 1389 1399 /**