Ticket #7769: 7769.2.diff
File 7769.2.diff, 14.9 KB (added by , 16 years ago) |
---|
-
wp-includes/comment-template.php
850 850 851 851 $args = wp_parse_args($args, $defaults); 852 852 853 if ( 0 == $args['depth'] || $args['max_depth'] < $args['depth'] )853 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) 854 854 return; 855 855 856 856 extract($args, EXTR_SKIP); … … 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' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', 982 'page' => get_query_var('cpage'), 'per_page' => ''); 982 983 983 984 $r = wp_parse_args( $args, $defaults ); 984 985 986 if ( '' === $r['per_page'] && get_option('page_comments') ) 987 $r['per_page'] = get_query_var('comments_per_page'); 988 989 if ( empty($r['per_page']) ) { 990 $r['page'] = 0; 991 } else { 992 $r['page'] = intval($r['page']); 993 if ( empty($r['page']) ) 994 $r['page'] = 1; 995 } 996 997 if ( '' === $r['depth'] ) { 998 if ( get_option('thread_comments') ) 999 $r['depth'] = get_option('thread_comments_depth'); 1000 else 1001 $r['depth'] = -1; 1002 } 1003 985 1004 extract( $r, EXTR_SKIP ); 986 1005 987 1006 if ( empty($walker) ) … … 995 1014 $wp_query->comments_by_type = &separate_comments($wp_query->comments); 996 1015 if ( empty($wp_query->comments_by_type[$type]) ) 997 1016 return; 998 return $walker->walk($wp_query->comments_by_type[$type], $depth, $r); 1017 $walker->paged_walk($wp_query->comments_by_type[$type], $depth, $page, $per_page, $r); 1018 $wp_query->max_num_comment_pages = $walker->max_pages; 1019 return; 999 1020 } 1000 $walker->walk($wp_query->comments, $depth, $r); 1021 $walker->paged_walk($wp_query->comments, $depth, $page, $per_page, $r); 1022 $wp_query->max_num_comment_pages = $walker->max_pages; 1001 1023 } else { 1002 1024 if ( empty($comments) ) 1003 1025 return; 1004 1026 if ( 'all' != $type ) { 1005 $comments_by_type = separate_comments($comments);1027 $comments_by_type = &separate_comments($comments); 1006 1028 if ( empty($comments_by_type[$type]) ) 1007 1029 return; 1008 return $walker->walk($comments_by_type[$type], $depth, $r); 1030 $walker->paged_walk($comments_by_type[$type], $depth, $page, $per_page, $r); 1031 $wp_query->max_num_comment_pages = $walker->max_pages; 1032 return; 1009 1033 } 1010 $walker->walk($comments, $depth, $r); 1034 $walker->paged_walk($comments, $depth, $page, $per_page, $r); 1035 $wp_query->max_num_comment_pages = $walker->max_pages; 1011 1036 } 1012 1037 } 1013 1038 -
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 834 if ( !$page ) 835 $page = 1; 836 837 $nextpage = intval($page) + 1; 838 839 if ( empty($max_page) ) 840 $max_page = $wp_query->max_num_comment_pages; 841 842 if ( $nextpage > $max_page ) 843 return; 844 845 if ( empty($label) ) 846 $label = __('» Newer Comments'); 847 848 echo '<a href="' . clean_url(get_comments_pagenum_link($nextpage)); 849 $attr = apply_filters( 'next_comments_link_attributes', '' ); 850 echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 851 } 852 853 function previous_comments_link($label='') { 854 global $wp_query; 855 856 if ( !is_singular() ) 857 return; 858 859 $page = get_query_var('cpage'); 860 861 if ( $page <= 1 ) 862 return; 863 864 $nextpage = intval($page) - 1; 865 866 if ( empty($label) ) 867 $label = __('« Older Comments'); 868 869 echo '<a href="' . clean_url(get_comments_pagenum_link($nextpage)); 870 $attr = apply_filters( 'previous_comments_link_attributes', '' ); 871 echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 872 } 873 796 874 function get_shortcut_link() { 797 875 $link = "javascript: 798 876 var d=document, -
wp-includes/formatting.php
1820 1820 case 'default_category': 1821 1821 case 'default_email_category': 1822 1822 case 'default_link_category': 1823 case 'close_comments_days_old': 1824 case 'comments_per_page': 1825 case 'thread_comments_depth': 1823 1826 $value = abs((int) $value); 1824 1827 break; 1825 1828 -
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 … … 947 956 function paged_walk( $elements, $max_depth, $page_num, $per_page ) { 948 957 949 958 /* sanity check */ 950 if ( empty($elements) || $max_depth < 0)959 if ( empty($elements) || $max_depth < -1 ) 951 960 return ''; 952 961 953 962 $args = array_slice( func_get_args(), 4 ); … … 956 965 $id_field = $this->db_fields['id']; 957 966 $parent_field = $this->db_fields['parent']; 958 967 968 $count = -1; 969 if ( -1 == $max_depth ) 970 $total_top = count( $elements ); 971 if ( $page_num < 1 || $per_page < 0 ) { 972 // No paging 973 $paging = false; 974 $start = 0; 975 if ( -1 == $max_depth ) 976 $end = $total_top; 977 $this->max_pages = 1; 978 } else { 979 $paging = true; 980 $start = ( (int)$page_num - 1 ) * (int)$per_page; 981 $end = $start + $per_page; 982 if ( -1 == $max_depth ) 983 $this->max_pages = ceil($total_top / $per_page); 984 } 985 986 // flat display 987 if ( -1 == $max_depth ) { 988 $empty_array = array(); 989 foreach ( $elements as $e ) { 990 $count++; 991 if ( $count < $start ) 992 continue; 993 if ( $count >= $end ) 994 break; 995 $this->display_element( $e, $empty_array, 1, 0, $args, $output ); 996 } 997 return $output; 998 } 999 959 1000 /* 960 1001 * seperate elements into two buckets: top level and children elements 961 1002 * children_elements is two dimensional array, eg. … … 970 1011 $children_elements[ $e->$parent_field ][] = $e; 971 1012 } 972 1013 973 $count = -1;974 1014 $total_top = count( $top_level_elements ); 975 if ( $page_num < 1 || $per_page < 0 ) {976 $start = 0;977 $end = $total_top;978 } else {979 $start = ( (int)$page_num - 1 ) * (int)$per_page;980 $end = $start + $per_page;981 }982 1015 1016 if ( $paging ) 1017 $this->max_pages = ceil($total_top / $per_page); 1018 983 1019 foreach( $top_level_elements as $e ){ 984 1020 $count++; 985 1021 … … 996 1032 $this->display_element( $e, $children_elements, $max_depth, 0, $args, $output ); 997 1033 } 998 1034 999 if ( $end >= $total_top && count( $children_elements ) > 0 ) {1035 if ( $end >= $total_top && count( $children_elements ) > 0 ) { 1000 1036 $empty_array = array(); 1001 1037 foreach ( $children_elements as $orphans ) 1002 1038 foreach( $orphans as $op ) … … 1030 1066 foreach ( (array)$children_elements[$id] as $child ) 1031 1067 $this->unset_children( $child, $children_elements ); 1032 1068 1033 unset( $children_elements[$id] ); 1069 if ( isset($children_elements[$id]) ) 1070 unset( $children_elements[$id] ); 1034 1071 1035 1072 } 1036 1073 } -
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 <div class="navigation"> 21 <div class="alignleft"><?php previous_comments_link() ?></div> 22 <div class="alignright"><?php next_comments_link() ?></div> 23 </div> 21 24 <?php else : // this is displayed if there are no comments so far ?> 22 25 23 26 <?php if ('open' == $post->comment_status) : ?> -
wp-admin/options-discussion.php
40 40 <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> /> 41 41 <?php _e('Close comments on articles older than') ?></label> <?php printf(__('%s days'), '<input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape(get_option('close_comments_days_old')) . '" size="3" />') ?> 42 42 <br /> 43 <label for="thread_comments"> 44 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> /> 45 <?php _e('Group replies into threads') ?></label> <?php printf(__('%s levels deep'), '<input name="thread_comments_depth" type="text" id="thread_comments_depth" value="' . attribute_escape(get_option('thread_comments_depth')) . '" size="3" />') ?> 46 <br /> 47 <label for="page_comments"> 48 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> /> 49 <?php _e('Break comments into pages with') ?></label> <?php printf(__('%s comments per page'), '<input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" size="3" />') ?> 50 <br /> 43 51 <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small> 44 52 </fieldset></td> 45 53 </tr> -
wp-admin/options.php
23 23 24 24 $whitelist_options = array( 25 25 'general' => array('blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'comment_registration', 'default_role' ), 26 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'close_comments_for_old_posts', 'close_comments_days_old' ),26 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page' ), 27 27 'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path' ), 28 28 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ), 29 29 'privacy' => array( 'blog_public' ),