Changeset 34669
- Timestamp:
- 09/28/2015 07:29:22 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r34569 r34669 1234 1234 } 1235 1235 1236 $flip_comment_order = $trim_comments_on_page = false; 1237 if ( $post->comment_count > $per_page ) { 1238 $comment_args['number'] = $per_page; 1239 1240 /* 1241 * For legacy reasons, higher page numbers always mean more recent comments, regardless of sort order. 1242 * Since we don't have full pagination info until after the query, we use some tricks to get the 1243 * right comments for the current page. 1244 * 1245 * Abandon all hope, ye who enter here! 1246 */ 1247 $page = (int) get_query_var( 'cpage' ); 1248 if ( 'newest' === get_option( 'default_comments_page' ) ) { 1249 if ( $page ) { 1250 $comment_args['order'] = 'ASC'; 1251 1252 /* 1253 * We don't have enough data (namely, the total number of comments) to calculate an 1254 * exact offset. We'll fetch too many comments, and trim them as needed 1255 * after the query. 1256 */ 1257 $offset = ( $page - 2 ) * $per_page; 1258 if ( 0 > $offset ) { 1259 // `WP_Comment_Query` doesn't support negative offsets. 1260 $comment_args['offset'] = 0; 1261 } else { 1262 $comment_args['offset'] = $offset; 1263 } 1264 1265 // Fetch double the number of comments we need. 1266 $comment_args['number'] += $per_page; 1267 $trim_comments_on_page = true; 1236 /* 1237 * For legacy reasons, higher page numbers always mean more recent comments, regardless of sort order. 1238 * Since we don't have full pagination info until after the query, we use some tricks to get the 1239 * right comments for the current page. 1240 * 1241 * Abandon all hope, ye who enter here! 1242 */ 1243 $flip_comment_order = $trim_comments_on_page= false; 1244 $comment_args['number'] = $per_page; 1245 $page = (int) get_query_var( 'cpage' ); 1246 if ( 'newest' === get_option( 'default_comments_page' ) ) { 1247 if ( $page ) { 1248 $comment_args['order'] = 'ASC'; 1249 1250 /* 1251 * We don't have enough data (namely, the total number of comments) to calculate an 1252 * exact offset. We'll fetch too many comments, and trim them as needed 1253 * after the query. 1254 */ 1255 $offset = ( $page - 2 ) * $per_page; 1256 if ( 0 > $offset ) { 1257 // `WP_Comment_Query` doesn't support negative offsets. 1258 $comment_args['offset'] = 0; 1268 1259 } else { 1269 $comment_args['order'] = 'DESC'; 1270 $comment_args['offset'] = 0; 1271 $flip_comment_order = true; 1260 $comment_args['offset'] = $offset; 1272 1261 } 1262 1263 // Fetch double the number of comments we need. 1264 $comment_args['number'] += $per_page; 1265 $trim_comments_on_page = true; 1273 1266 } else { 1274 $comment_args['order'] = 'ASC'; 1275 if ( $page ) { 1276 $comment_args['offset'] = ( $page - 1 ) * $per_page; 1277 } else { 1278 $comment_args['offset'] = 0; 1279 } 1267 $comment_args['order'] = 'DESC'; 1268 $comment_args['offset'] = 0; 1269 $flip_comment_order = true; 1270 } 1271 } else { 1272 $comment_args['order'] = 'ASC'; 1273 if ( $page ) { 1274 $comment_args['offset'] = ( $page - 1 ) * $per_page; 1275 } else { 1276 $comment_args['offset'] = 0; 1280 1277 } 1281 1278 } … … 1284 1281 $_comments = $comment_query->comments; 1285 1282 1286 // Delightful pagination quirk #1: first page of results sometimes needs reordering.1283 // Delightful pagination quirk #1: `wp_list_comments()` expects the order to be wrong, so we make it wrong. 1287 1284 if ( $flip_comment_order ) { 1288 1285 $_comments = array_reverse( $_comments );
Note: See TracChangeset
for help on using the changeset viewer.