Ticket #7927: 7927.4.patch
| File 7927.4.patch, 13.1 KB (added by , 17 years ago) |
|---|
-
wp-admin/includes/schema.php
288 288 add_option('image_default_align', ''); 289 289 add_option('close_comments_for_old_posts', 0); 290 290 add_option('close_comments_days_old', 14); 291 add_option('thread_comments', 0); 292 add_option('thread_comments_depth', 5); 293 add_option('page_comments', 1); 294 add_option('comments_per_page', 10); 295 add_option('default_comments_page', 'newest'); 296 add_option('comment_order', 'asc'); 291 297 292 298 // Delete unused options 293 299 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins'); -
wp-admin/options-discussion.php
43 43 <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> /> 44 44 <?php _e('Allow people to post comments on the article') ?></label> 45 45 <br /> 46 <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small> 47 </fieldset></td> 48 </tr> 49 <tr valign="top"> 50 <th scope="row"><?php _e('Other comment settings') ?></th> 51 <td><fieldset><legend class="hidden"><?php _e('Other comment settings') ?></legend> 46 52 <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label> 47 53 <br /> 48 54 <label for="close_comments_for_old_posts"> 49 55 <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')); ?> /> 50 <?php printf( __(' Close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape(get_option('close_comments_days_old')) . '" size="3" />') ?>56 <?php printf( __('Automatically close comments on articles older than %s days'), '</label><input name="close_comments_days_old" type="text" id="close_comments_days_old" value="' . attribute_escape(get_option('close_comments_days_old')) . '" size="3" />') ?> 51 57 <br /> 52 58 <label for="thread_comments"> 53 59 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> /> … … 68 74 ?><br /> 69 75 <label for="page_comments"> 70 76 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> /> 71 <?php printf( __('Break comments into pages with %s comments per page'), '</label><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" size="3" />') ?> 77 <?php 78 79 $default_comments_page = '</label><select name="default_comments_page" id="default_comments_page"><option value="newest"'; 80 if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; 81 $default_comments_page .= '>' . __('last') . '</option><option value="oldest"'; 82 if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"'; 83 $default_comments_page .= '>' . __('first') . '</option></select>'; 84 85 printf( __('Break comments into pages with %1$s comments per page and the %2$s page displayed by default'), '</label><input name="comments_per_page" type="text" id="comments_per_page" value="' . attribute_escape(get_option('comments_per_page')) . '" size="3" />', $default_comments_page ); 86 87 ?> 72 88 <br /> 73 <small><em><?php echo '(' . __('These settings may be overridden for individual articles.') . ')'; ?></em></small> 89 <label for="comment_order"><?php 90 91 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"'; 92 if ( 'asc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; 93 $comment_order .= '>' . __('oldest') . '</option><option value="desc"'; 94 if ( 'desc' == get_option('comment_order') ) $comment_order .= ' selected="selected"'; 95 $comment_order .= '>' . __('newest') . '</option></select>'; 96 97 printf( __('Comments should be displayed with the %s comments on top'), $comment_order ); 98 99 ?></label> 74 100 </fieldset></td> 75 101 </tr> 76 102 <tr valign="top"> -
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', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page' ),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' ), 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' ), -
wp-includes/classes.php
985 985 986 986 // flat display 987 987 if ( -1 == $max_depth ) { 988 if ( !empty($args[0]['reverse_top_level']) ) 989 $elements = array_reverse( $elements ); 990 988 991 $empty_array = array(); 989 992 foreach ( $elements as $e ) { 990 993 $count++; … … 1017 1020 else 1018 1021 $end = $total_top; 1019 1022 1020 foreach( $top_level_elements as $e ){ 1023 if ( !empty($args[0]['reverse_top_level']) ) { 1024 $top_level_elements = array_reverse( $top_level_elements ); 1025 $oldstart = $start; 1026 $start = $total_top - $end; 1027 $end = $total_top - $oldstart; 1028 } 1029 if ( !empty($args[0]['reverse_children']) ) { 1030 foreach ( $children_elements as $parent => $children ) 1031 $children_elements[$parent] = array_reverse( $children ); 1032 } 1033 1034 foreach ( $top_level_elements as $e ) { 1021 1035 $count++; 1022 1036 1023 1037 //for the last page, need to unset earlier children in order to keep track of orphans -
wp-includes/comment-template.php
762 762 $comments_by_type = &$wp_query->comments_by_type; 763 763 } 764 764 765 if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') ) 766 set_query_var( 'cpage', get_comment_pages_count() ); 767 765 768 define('COMMENTS_TEMPLATE', true); 766 769 767 770 $include = apply_filters('comments_template', STYLESHEETPATH . $file ); … … 1122 1125 * @since 2.7.0 1123 1126 * @uses Walker_Comment 1124 1127 * 1125 * @param $args string|arrayFormatting options1126 * @param $comments arrayOptional array of comment objects. Defaults to $wp_query->comments1128 * @param string|array $args Formatting options 1129 * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments 1127 1130 */ 1128 1131 function wp_list_comments($args = array(), $comments = null ) { 1129 1132 global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt; … … 1132 1135 $comment_depth = 1; 1133 1136 1134 1137 $defaults = array('walker' => null, 'depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all', 1135 'page' => get_query_var('cpage'), 'per_page' => '', 'avatar_size' => 32);1138 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => '', 'reverse_children' => ''); 1136 1139 1137 1140 $r = wp_parse_args( $args, $defaults ); 1138 1141 … … 1142 1145 if ( empty($r['per_page']) ) { 1143 1146 $r['per_page'] = 0; 1144 1147 $r['page'] = 0; 1145 } else {1146 $r['page'] = intval($r['page']);1147 if ( empty($r['page']) )1148 $r['page'] = 1;1149 1148 } 1150 1149 1151 1150 if ( '' === $r['depth'] ) { … … 1155 1154 $r['depth'] = -1; 1156 1155 } 1157 1156 1157 if ( '' === $r['page'] ) { 1158 if ( empty($comments) ) { 1159 $r['page'] = get_query_var('cpage'); 1160 } else { 1161 $threaded = ( -1 == $r['depth'] ) ? false : true; 1162 $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1; 1163 set_query_var( 'cpage', $r['page'] ); 1164 } 1165 } 1166 // Validation check 1167 $r['page'] = intval($r['page']); 1168 if ( 0 == $r['page'] && 0 != $r['per_page'] ) 1169 $r['page'] = 1; 1170 1171 if ( '' == $r['reverse_top_level'] ) 1172 $r['reverse_top_level'] = ( 'asc' == get_option('comment_order') ) ? FALSE : TRUE; 1173 1158 1174 extract( $r, EXTR_SKIP ); 1159 1175 1160 1176 if ( empty($walker) ) -
wp-includes/comment.php
481 481 } 482 482 483 483 /** 484 * Calculate the total number of comment pages. 485 * 486 * @since 2.7.0 487 * 488 * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments 489 * @param int $per_page Optional comments per page. 490 * @param boolean $threaded Optional control over flat or threaded comments. 491 * @return int Number of comment pages. 492 */ 493 function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) { 494 global $wp_query; 495 496 if ( !$comments ) 497 $comments = $wp_query->comments; 498 499 if ( !$comments ) 500 return 0; 501 502 if ( !$per_page ) 503 $per_page = get_query_var('comments_per_page'); 504 505 if ( !$threaded ) 506 $threaded = get_option('thread_comments'); 507 508 if ( $threaded ) { 509 $walker = new Walker_Comment; 510 $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page ); 511 } else { 512 $count = ceil( count( $comments ) / $per_page ); 513 } 514 515 return $count; 516 } 517 518 /** 484 519 * Does comment contain blacklisted characters or words. 485 520 * 486 521 * @since 1.5.0 -
wp-includes/link-template.php
1135 1135 * @param int $pagenum Optional. Page number. 1136 1136 * @return string 1137 1137 */ 1138 function get_comments_pagenum_link( $pagenum = 1) {1138 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { 1139 1139 global $wp_rewrite; 1140 1140 1141 1141 $pagenum = (int) $pagenum; … … 1151 1151 1152 1152 $base = trailingslashit( get_bloginfo( 'home' ) ); 1153 1153 1154 if ( $pagenum > 1 ) { 1154 $result = $base . $request; 1155 1156 if ( 'newest' == get_option('default_comments_page') ) { 1157 if ( $pagenum != $max_page ) 1158 $result = add_query_arg( 'cpage', $pagenum, $base . $request ); 1159 } elseif ( $pagenum > 1 ) 1155 1160 $result = add_query_arg( 'cpage', $pagenum, $base . $request ); 1156 } else {1157 $result = $base . $request;1158 }1159 1161 1160 1162 $result .= '#comments'; 1161 1163 … … 1194 1196 if ( empty($label) ) 1195 1197 $label = __('» Newer Comments'); 1196 1198 1197 echo '<a href="' . clean_url( get_comments_pagenum_link($nextpage));1199 echo '<a href="' . clean_url( get_comments_pagenum_link( $nextpage, $max_page ) ); 1198 1200 $attr = apply_filters( 'next_comments_link_attributes', '' ); 1199 1201 echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>'; 1200 1202 }