WordPress.org

Make WordPress Core

Ticket #9023: 9023_improve_paged_comments.diff

File 9023_improve_paged_comments.diff, 9.1 KB (added by hailin, 5 years ago)

revised patch

  • C:/xampp/htdocs/wordpress_trunk/wp-includes/comment-template.php

     
    834834 
    835835        $overridden_cpage = FALSE; 
    836836        if ( '' == get_query_var('cpage') && get_option('page_comments') ) { 
    837                 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); 
     837                set_query_var( 'cpage', 'desc' == get_option('comment_order') ? get_comment_pages_count() : 1 ); 
    838838                $overridden_cpage = TRUE; 
    839839        } 
    840840 
     
    12851285        $comment_depth = 1; 
    12861286 
    12871287        $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', 
    1288                 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => ''); 
     1288                'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null); 
    12891289 
    12901290        $r = wp_parse_args( $args, $defaults ); 
    12911291 
     
    13361336                        $r['page'] = get_query_var('cpage'); 
    13371337                } else { 
    13381338                        $threaded = ( -1 == $r['max_depth'] ) ? false : true; 
    1339                         $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; 
     1339                        $r['page'] = ( 'desc' == get_option('comment_order') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; 
    13401340                        set_query_var( 'cpage', $r['page'] ); 
    13411341                } 
    13421342        } 
  • C:/xampp/htdocs/wordpress_trunk/wp-includes/link-template.php

     
    12231223 
    12241224        $result = get_permalink( $post->ID ); 
    12251225 
    1226         if ( 'newest' == get_option('default_comments_page') ) { 
     1226        if ( 'desc' == get_option('comment_order') ) { 
    12271227                if ( $pagenum != $max_page ) { 
    12281228                        if ( $wp_rewrite->using_permalinks() ) 
    12291229                                $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged'); 
  • C:/xampp/htdocs/wordpress_trunk/wp-includes/canonical.php

     
    163163                                } 
    164164                        } 
    165165 
    166                         if ( get_option('page_comments') && ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) ) { 
     166                        if ( get_option('page_comments') && ( ( 'desc' == get_option('comment_order') && get_query_var('cpage') > 0 ) || ( 'desc' != get_option('comment_order') && get_query_var('cpage') > 1 ) ) ) { 
    167167                                $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( 'comment-page-' . get_query_var('cpage'), 'commentpaged' ); 
    168168                                $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); 
    169169                        } 
  • C:/xampp/htdocs/wordpress_trunk/wp-includes/classes.php

     
    952952         * 
    953953         * @package WordPress 
    954954         * @since 2.7 
    955          * @param $max_depth = 0  means display all levels; $max_depth > 0  specifies the number of display levels. 
     955         * @param $max_depth = -1 means flat display; $max_depth = 0  means display all levels; $max_depth > 0  specifies the number of display levels. 
    956956         * @param $page_num the specific page number, beginning with 1. 
    957957         * @return XHTML of the specified page of elements 
    958958         */ 
     
    10281028                        $end = $total_top; 
    10291029 
    10301030                if ( !empty($args[0]['reverse_top_level']) ) { 
     1031                         
    10311032                        $top_level_elements = array_reverse( $top_level_elements ); 
    10321033                        $oldstart = $start; 
    10331034                        $start = $total_top - $end; 
    10341035                        $end = $total_top - $oldstart; 
    1035                 } 
    1036                 if ( !empty($args[0]['reverse_children']) ) { 
     1036                         
    10371037                        foreach ( $children_elements as $parent => $children ) 
    10381038                                $children_elements[$parent] = array_reverse( $children ); 
    10391039                } 
  • C:/xampp/htdocs/wordpress_trunk/wp-admin/includes/schema.php

     
    292292        add_option('thread_comments_depth', 5); 
    293293        add_option('page_comments', 1); 
    294294        add_option('comments_per_page', 50); 
    295         add_option('default_comments_page', 'newest'); 
    296295        add_option('comment_order', 'asc'); 
    297296        add_option('use_ssl', 0); 
    298297        add_option('sticky_posts', array()); 
  • C:/xampp/htdocs/wordpress_trunk/wp-admin/options-discussion.php

     
    7777<input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> /> 
    7878<?php 
    7979 
    80 $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"'; 
    81 if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; 
    82 $default_comments_page .= '>' . __('last') . '</option><option value="oldest"'; 
    83 if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; 
    84 $default_comments_page .= '>' . __('first') . '</option></select>'; 
    85  
    86 printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page ); 
    87  
    88 ?></label> 
    89 <br /> 
    90 <label for="comment_order"><?php 
    91  
    92 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"'; 
     80$comment_order = '</label><label for="comment_order"><select name="comment_order" id="comment_order"><option value="asc"'; 
    9381if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; 
    9482$comment_order .= '>' . __('older') . '</option><option value="desc"'; 
    9583if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; 
    9684$comment_order .= '>' . __('newer') . '</option></select>'; 
    9785 
    98 printf( __('Comments should be displayed with the %s comments at the top of each page'), $comment_order ); 
     86printf( __('Break comments into pages with %1$s top level comments per page and display %2$s comments first'), '</label><label for="comments_per_page"><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" class="small-text" />', $comment_order ); 
    9987 
    10088?></label> 
     89<br /> 
     90 
    10191</fieldset></td> 
    10292</tr> 
    10393<tr valign="top"> 
  • C:/xampp/htdocs/wordpress_trunk/wp-admin/options.php

     
    2323 
    2424$whitelist_options = array( 
    2525        'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', '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', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), 
     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', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'comment_order', 'comment_registration' ), 
    2727        'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path' ), 
    2828        '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' ), 
    2929        'privacy' => array( 'blog_public' ),