Ticket #7769: 7769.diff
File 7769.diff, 8.2 KB (added by , 17 years ago) |
---|
-
wp-includes/comment-template.php
973 973 * @uses Walker_Comment 974 974 * 975 975 * @param $args string|array Formatting options 976 976 * @param $comments array Optional array of comment objects. Defaults to $wp_query->comments 977 977 */ 978 978 function wp_list_comments($args = array(), $comments = null ) { 979 979 global $wp_query; 980 980 981 $defaults = array('walker' => null, 'depth' => 3, 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all'); 981 $defaults = array('walker' => null, 'depth' => 10, 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', 982 'page' => get_query_var('cpage'), 'per_page' => get_query_var('comments_per_page')); 982 983 983 984 $r = wp_parse_args( $args, $defaults ); 985 $r['per_page'] = 2; // Hardcoded for testing 986 if ( empty($r['per_page']) ) { 987 $r['page'] = 0; 988 } else { 989 $r['page'] = intval($r['page']); 990 if ( empty($r['page']) ) 991 $r['page'] = 1; 992 } 984 993 985 994 extract( $r, EXTR_SKIP ); 986 995 … … 995 1004 $wp_query->comments_by_type = &separate_comments($wp_query->comments); 996 1005 if ( empty($wp_query->comments_by_type[$type]) ) 997 1006 return; 998 return $walker->walk($wp_query->comments_by_type[$type], $depth, $r); 1007 $walker->paged_walk($wp_query->comments_by_type[$type], $depth, $page, $per_page, $r); 1008 $wp_query->max_num_comment_pages = $walker->max_pages; 1009 return; 999 1010 } 1000 $walker->walk($wp_query->comments, $depth, $r); 1011 $walker->paged_walk($wp_query->comments, $depth, $page, $per_page, $r); 1012 $wp_query->max_num_comment_pages = $walker->max_pages; 1001 1013 } else { 1002 1014 if ( empty($comments) ) 1003 1015 return; 1004 1016 if ( 'all' != $type ) { 1005 $comments_by_type = separate_comments($comments);1017 $comments_by_type = &separate_comments($comments); 1006 1018 if ( empty($comments_by_type[$type]) ) 1007 1019 return; 1008 return $walker->walk($comments_by_type[$type], $depth, $r); 1020 $walker->paged_walk($comments_by_type[$type], $depth, $page, $per_page, $r); 1021 $wp_query->max_num_comment_pages = $walker->max_pages; 1022 return; 1009 1023 } 1010 $walker->walk($comments, $depth, $r); 1024 $walker->paged_walk($comments, $depth, $page, $per_page, $r); 1025 $wp_query->max_num_comment_pages = $walker->max_pages; 1011 1026 } 1012 1027 } 1013 1028 -
wp-includes/query.php
844 844 var $max_num_pages = 0; 845 845 846 846 /** 847 * The amount of comment pages. 848 * 849 * @since 2.7.0 850 * @access public 851 * @var int 852 */ 853 var $max_num_comment_pages = 0; 854 855 /** 847 856 * Set if query is single post. 848 857 * 849 858 * @since 1.5.0 … … 1612 1621 else if ( $q['posts_per_page'] == 0 ) 1613 1622 $q['posts_per_page'] = 1; 1614 1623 1624 if ( !isset($q['comments_per_page']) || $q['comments_per_page'] == 0 ) 1625 $q['comments_per_page'] = get_option('comments_per_page'); 1626 1615 1627 if ( $this->is_home && (empty($this->query) || $q['preview'] == 'true') && ( 'page' == get_option('show_on_front') ) && get_option('page_on_front') ) { 1616 1628 $this->is_page = true; 1617 1629 $this->is_home = false; -
wp-includes/link-template.php
793 793 } 794 794 } 795 795 796 function get_comments_pagenum_link($pagenum = 1) { 797 global $wp_rewrite; 798 799 $pagenum = (int) $pagenum; 800 801 $request = remove_query_arg( 'cpage' ); 802 803 $home_root = parse_url(get_option('home')); 804 $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : ''; 805 $home_root = preg_quote( trailingslashit( $home_root ), '|' ); 806 807 $request = preg_replace('|^'. $home_root . '|', '', $request); 808 $request = preg_replace('|^/+|', '', $request); 809 810 $base = trailingslashit( get_bloginfo( 'home' ) ); 811 812 if ( $pagenum > 1 ) { 813 $result = add_query_arg( 'cpage', $pagenum, $base . $request ); 814 } else { 815 $result = $base . $request; 816 } 817 818 $result = apply_filters('get_comments_pagenum_link', $result); 819 820 return $result; 821 } 822 823 function next_comments_link($label='', $max_page = 0) { 824 global $wp_query; 825 826 if ( !is_singular() ) 827 return; 828 829 $page = get_query_var('cpage'); 830 831 if ( !$page ) 832 $page = 1; 833 $nextpage = intval($page) + 1; 834 835 if ( empty($max_page) ) 836 $max_page = $wp_query->max_num_comment_pages; 837 838 if ( empty($label) ) 839 $label = __('» Newer Comments'); 840 841 if ( $nextpage > $max_page ) 842 return; 843 844 echo '<a href="' . clean_url(get_comments_pagenum_link($nextpage)); 845 $attr = apply_filters( 'next_comments_link_attributes', '' ); 846 echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 847 } 848 796 849 function get_shortcut_link() { 797 850 $link = "javascript: 798 851 var d=document, -
wp-includes/classes.php
26 26 * @access public 27 27 * @var array 28 28 */ 29 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term' );29 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage'); 30 30 31 31 /** 32 32 * Private query variables. … … 36 36 * @since 2.0.0 37 37 * @var array 38 38 */ 39 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm' );39 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm', 'comments_per_page'); 40 40 41 41 /** 42 42 * Extra query variables set by the user. … … 731 731 var $db_fields; 732 732 733 733 /** 734 * Max number of pages walked by the paged walker 735 * 736 * @since 2.7.0 737 * @var int 738 * @access protected 739 */ 740 var $max_pages = 1; 741 742 /** 734 743 * Starts the list before the elements are added. 735 744 * 736 745 * Additional parameters are used in child classes. The args parameter holds … … 975 984 if ( $page_num < 1 || $per_page < 0 ) { 976 985 $start = 0; 977 986 $end = $total_top; 987 $this->max_pages = 1; 978 988 } else { 979 989 $start = ( (int)$page_num - 1 ) * (int)$per_page; 980 990 $end = $start + $per_page; 991 $this->max_pages = ceil($total_top / $per_page); 981 992 } 982 993 983 994 foreach( $top_level_elements as $e ){ -
wp-content/themes/default/comments.php
15 15 <h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3> 16 16 17 17 <ol class="commentlist"> 18 <?php wp_list_comments( $comments); ?>18 <?php wp_list_comments(); ?> 19 19 </ol> 20 20 <?php next_comments_link(); ?> 21 21 <?php else : // this is displayed if there are no comments so far ?> 22 22 23 23 <?php if ('open' == $post->comment_status) : ?>