| | 1216 | // Figure out what comments we'll be looping through ($_comments) |
| | 1217 | if ( null !== $comments ) { |
| | 1218 | $comments = (array) $comments; |
| | 1219 | if ( empty($comments) ) |
| | 1220 | return; |
| | 1221 | if ( 'all' != $r['type'] ) { |
| | 1222 | $comments_by_type = &separate_comments($comments); |
| | 1223 | if ( empty($comments_by_type[$r['type']]) ) |
| | 1224 | return; |
| | 1225 | $_comments = $comments_by_type[$r['type']]; |
| | 1226 | } else { |
| | 1227 | $_comments = $comments; |
| | 1228 | } |
| | 1229 | } else { |
| | 1230 | if ( empty($wp_query->comments) ) |
| | 1231 | return; |
| | 1232 | if ( 'all' != $r['type'] ) { |
| | 1233 | if ( empty($wp_query->comments_by_type) ) |
| | 1234 | $wp_query->comments_by_type = &separate_comments($wp_query->comments); |
| | 1235 | if ( empty($wp_query->comments_by_type[$r['type']]) ) |
| | 1236 | return; |
| | 1237 | $_comments = $wp_query->comments_by_type[$r['type']]; |
| | 1238 | } else { |
| | 1239 | $_comments = $wp_query->comments; |
| | 1240 | } |
| | 1241 | } |
| | 1242 | |
| 1235 | | if ( empty($overridden_cpage) ) { |
| 1236 | | $r['page'] = get_query_var('cpage'); |
| 1237 | | } else { |
| 1238 | | $threaded = ( -1 == $r['max_depth'] ) ? false : true; |
| 1239 | | $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1; |
| 1240 | | set_query_var( 'cpage', $r['page'] ); |
| 1241 | | } |
| | 1262 | $threaded = ( -1 == $r['max_depth'] ) ? false : true; |
| | 1263 | $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
| | 1264 | set_query_var( 'cpage', $r['page'] ); |
| 1257 | | if ( empty($comments) ) { |
| 1258 | | if ( empty($wp_query->comments) ) |
| 1259 | | return; |
| 1260 | | if ( 'all' != $type ) { |
| 1261 | | if ( empty($wp_query->comments_by_type) ) |
| 1262 | | $wp_query->comments_by_type = &separate_comments($wp_query->comments); |
| 1263 | | if ( empty($wp_query->comments_by_type[$type]) ) |
| 1264 | | return; |
| 1265 | | $walker->paged_walk($wp_query->comments_by_type[$type], $max_depth, $page, $per_page, $r); |
| 1266 | | $wp_query->max_num_comment_pages = $walker->max_pages; |
| 1267 | | return; |
| 1268 | | } |
| 1269 | | $walker->paged_walk($wp_query->comments, $max_depth, $page, $per_page, $r); |
| 1270 | | $wp_query->max_num_comment_pages = $walker->max_pages; |
| 1271 | | } else { |
| 1272 | | if ( empty($comments) ) |
| 1273 | | return; |
| 1274 | | if ( 'all' != $type ) { |
| 1275 | | $comments_by_type = &separate_comments($comments); |
| 1276 | | if ( empty($comments_by_type[$type]) ) |
| 1277 | | return; |
| 1278 | | $walker->paged_walk($comments_by_type[$type], $max_depth, $page, $per_page, $r); |
| 1279 | | $wp_query->max_num_comment_pages = $walker->max_pages; |
| 1280 | | return; |
| 1281 | | } |
| 1282 | | $walker->paged_walk($comments, $max_depth, $page, $per_page, $r); |
| 1283 | | $wp_query->max_num_comment_pages = $walker->max_pages; |
| 1284 | | } |
| | 1280 | $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r); |
| | 1281 | $wp_query->max_num_comment_pages = $walker->max_pages; |