Changeset 9808 for trunk/wp-includes/comment-template.php
- Timestamp:
- 11/20/2008 06:41:55 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment-template.php
r9781 r9808 442 442 * 443 443 * @param object|string|int $comment Comment to retrieve. 444 * @param string|int $page The comment's page if known. Optional. Avoids extra database query.444 * @param array $args Optional args. 445 445 * @return string The permalink to the current comment 446 446 */ 447 function get_comment_link( $comment = null, $ page = null) {448 global $wp_rewrite ;447 function get_comment_link( $comment = null, $args = array() ) { 448 global $wp_rewrite, $in_comment_loop; 449 449 450 450 $comment = get_comment($comment); 451 451 452 if ( get_option('page_comments') ) { 453 $page = ( null !== $page ) ? (int) $page : get_page_of_comment( $comment->comment_ID ); 452 // Backwards compat 453 if ( !is_array($args) ) { 454 $page = $args; 455 $args = array(); 456 $args['page'] = $page; 457 } 458 459 $defaults = array( 'type' => 'all', 'page' => '', 'per_page' => '', 'max_depth' => '' ); 460 $args = wp_parse_args( $args, $defaults ); 461 462 if ( '' === $args['per_page'] && get_option('page_comments') ) 463 $args['per_page'] = get_query_var('comments_per_page'); 464 465 if ( empty($args['per_page']) ) { 466 $args['per_page'] = 0; 467 $args['page'] = 0; 468 } 469 470 if ( $args['per_page'] ) { 471 if ( '' == $args['page'] ) 472 $args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args ); 454 473 455 474 if ( $wp_rewrite->using_permalinks() ) 456 return user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . "comment-page-$page", 'comment' ) . '#comment-' . $comment->comment_ID;475 return user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' ) . '#comment-' . $comment->comment_ID; 457 476 else 458 return add_query_arg( 'cpage', $ page, get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID;477 return add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) ) . '#comment-' . $comment->comment_ID; 459 478 } else { 460 479 return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID; … … 1163 1182 <?php endif; ?> 1164 1183 1165 <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID , $page) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date('F jS, Y'), get_comment_time()) ?></a><?php edit_comment_link('edit',' ','') ?></div>1184 <div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date('F jS, Y'), get_comment_time()) ?></a><?php edit_comment_link('edit',' ','') ?></div> 1166 1185 1167 1186 <?php comment_text() ?> … … 1210 1229 */ 1211 1230 function wp_list_comments($args = array(), $comments = null ) { 1212 global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage; 1231 global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop; 1232 1233 $in_comment_loop = true; 1213 1234 1214 1235 $comment_alt = $comment_thread_alt = 0; … … 1286 1307 $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r); 1287 1308 $wp_query->max_num_comment_pages = $walker->max_pages; 1309 1310 $in_comment_loop = false; 1288 1311 } 1289 1312
Note: See TracChangeset
for help on using the changeset viewer.