Index: /trunk/wp-admin/includes/schema.php
===================================================================
--- /trunk/wp-admin/includes/schema.php (revision 9295)
+++ /trunk/wp-admin/includes/schema.php (revision 9296)
@@ -289,4 +289,10 @@
add_option('close_comments_for_old_posts', 0);
add_option('close_comments_days_old', 14);
+ add_option('thread_comments', 0);
+ add_option('thread_comments_depth', 5);
+ add_option('page_comments', 1);
+ add_option('comments_per_page', 10);
+ add_option('default_comments_page', 'newest');
+ add_option('comment_order', 'asc');
// Delete unused options
Index: /trunk/wp-admin/options-discussion.php
===================================================================
--- /trunk/wp-admin/options-discussion.php (revision 9295)
+++ /trunk/wp-admin/options-discussion.php (revision 9296)
@@ -44,9 +44,15 @@
+
+
+
+
+ |
+ |
Index: /trunk/wp-admin/options.php
===================================================================
--- /trunk/wp-admin/options.php (revision 9295)
+++ /trunk/wp-admin/options.php (revision 9296)
@@ -24,5 +24,5 @@
$whitelist_options = array(
'general' => array('blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'comment_registration', 'default_role' ),
- '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' ),
+ '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' ),
'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path' ),
'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' ),
Index: /trunk/wp-comments-post.php
===================================================================
--- /trunk/wp-comments-post.php (revision 9295)
+++ /trunk/wp-comments-post.php (revision 9296)
@@ -80,5 +80,8 @@
}
-$location = ( empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to'] ) . '#comment-' . $comment_id;
+if ( empty($_POST['redirect_to']) )
+ $postlink = ( 'newest' == get_option('default_comments_page') ) ? get_permalink($comment_post_ID) : add_query_arg( 'cpage', get_comment_pages_count( get_comments( array( 'post_id' => $comment_post_ID ) ) ), get_permalink($comment_post_ID) );
+
+$location = ( empty($_POST['redirect_to']) ? $postlink : $_POST['redirect_to'] ) . '#comment-' . $comment_id;
$location = apply_filters('comment_post_redirect', $location, $comment);
Index: /trunk/wp-includes/classes.php
===================================================================
--- /trunk/wp-includes/classes.php (revision 9295)
+++ /trunk/wp-includes/classes.php (revision 9296)
@@ -986,4 +986,11 @@
// flat display
if ( -1 == $max_depth ) {
+ if ( !empty($args[0]['reverse_top_level']) ) {
+ $elements = array_reverse( $elements );
+ $oldstart = $start;
+ $start = $total_top - $end;
+ $end = $total_top - $oldstart;
+ }
+
$empty_array = array();
foreach ( $elements as $e ) {
@@ -1018,5 +1025,16 @@
$end = $total_top;
- foreach( $top_level_elements as $e ){
+ if ( !empty($args[0]['reverse_top_level']) ) {
+ $top_level_elements = array_reverse( $top_level_elements );
+ $oldstart = $start;
+ $start = $total_top - $end;
+ $end = $total_top - $oldstart;
+ }
+ if ( !empty($args[0]['reverse_children']) ) {
+ foreach ( $children_elements as $parent => $children )
+ $children_elements[$parent] = array_reverse( $children );
+ }
+
+ foreach ( $top_level_elements as $e ) {
$count++;
Index: /trunk/wp-includes/comment-template.php
===================================================================
--- /trunk/wp-includes/comment-template.php (revision 9295)
+++ /trunk/wp-includes/comment-template.php (revision 9296)
@@ -762,4 +762,7 @@
$comments_by_type = &$wp_query->comments_by_type;
}
+
+ if ( '' == get_query_var('cpage') && get_option('page_comments') && 'newest' == get_option('default_comments_page') )
+ set_query_var( 'cpage', get_comment_pages_count() );
define('COMMENTS_TEMPLATE', true);
@@ -1123,6 +1126,6 @@
* @uses Walker_Comment
*
- * @param $args string|array Formatting options
- * @param $comments array Optional array of comment objects. Defaults to $wp_query->comments
+ * @param string|array $args Formatting options
+ * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
*/
function wp_list_comments($args = array(), $comments = null ) {
@@ -1133,5 +1136,5 @@
$defaults = array('walker' => null, 'depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
- 'page' => get_query_var('cpage'), 'per_page' => '', 'avatar_size' => 32);
+ 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => '', 'reverse_children' => '');
$r = wp_parse_args( $args, $defaults );
@@ -1143,8 +1146,4 @@
$r['per_page'] = 0;
$r['page'] = 0;
- } else {
- $r['page'] = intval($r['page']);
- if ( empty($r['page']) )
- $r['page'] = 1;
}
@@ -1155,4 +1154,21 @@
$r['depth'] = -1;
}
+
+ if ( '' === $r['page'] ) {
+ if ( empty($comments) ) {
+ $r['page'] = get_query_var('cpage');
+ } else {
+ $threaded = ( -1 == $r['depth'] ) ? false : true;
+ $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($comments, $r['per_page'], $threaded) : 1;
+ set_query_var( 'cpage', $r['page'] );
+ }
+ }
+ // Validation check
+ $r['page'] = intval($r['page']);
+ if ( 0 == $r['page'] && 0 != $r['per_page'] )
+ $r['page'] = 1;
+
+ if ( '' == $r['reverse_top_level'] )
+ $r['reverse_top_level'] = ( 'asc' == get_option('comment_order') ) ? FALSE : TRUE;
extract( $r, EXTR_SKIP );
Index: /trunk/wp-includes/comment.php
===================================================================
--- /trunk/wp-includes/comment.php (revision 9295)
+++ /trunk/wp-includes/comment.php (revision 9296)
@@ -482,4 +482,43 @@
/**
+ * Calculate the total number of comment pages.
+ *
+ * @since 2.7.0
+ *
+ * @param array $comments Optional array of comment objects. Defaults to $wp_query->comments
+ * @param int $per_page Optional comments per page.
+ * @param boolean $threaded Optional control over flat or threaded comments.
+ * @return int Number of comment pages.
+ */
+function get_comment_pages_count( $comments = null, $per_page = null, $threaded = null ) {
+ global $wp_query;
+
+ if ( !$comments || !is_array($comments) )
+ $comments = $wp_query->comments;
+
+ if ( empty($comments) )
+ return 0;
+
+ if ( !isset($per_page) )
+ $per_page = (int) get_query_var('comments_per_page');
+ if ( 0 === $per_page )
+ $per_page = (int) get_option('comments_per_page');
+ if ( 0 === $per_page )
+ return 1;
+
+ if ( !isset($threaded) )
+ $threaded = get_option('thread_comments');
+
+ if ( $threaded ) {
+ $walker = new Walker_Comment;
+ $count = ceil( $walker->get_number_of_root_elements( $comments ) / $per_page );
+ } else {
+ $count = ceil( count( $comments ) / $per_page );
+ }
+
+ return $count;
+}
+
+/**
* Does comment contain blacklisted characters or words.
*
Index: /trunk/wp-includes/link-template.php
===================================================================
--- /trunk/wp-includes/link-template.php (revision 9295)
+++ /trunk/wp-includes/link-template.php (revision 9296)
@@ -1136,5 +1136,5 @@
* @return string
*/
-function get_comments_pagenum_link($pagenum = 1) {
+function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
global $wp_rewrite;
@@ -1152,9 +1152,11 @@
$base = trailingslashit( get_bloginfo( 'home' ) );
- if ( $pagenum > 1 ) {
+ $result = $base . $request;
+
+ if ( 'newest' == get_option('default_comments_page') ) {
+ if ( $pagenum != $max_page )
+ $result = add_query_arg( 'cpage', $pagenum, $base . $request );
+ } elseif ( $pagenum > 1 )
$result = add_query_arg( 'cpage', $pagenum, $base . $request );
- } else {
- $result = $base . $request;
- }
$result .= '#comments';
@@ -1195,5 +1197,5 @@
$label = __('» Newer Comments');
- echo '". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'';
Index: /trunk/wp-includes/version.php
===================================================================
--- /trunk/wp-includes/version.php (revision 9295)
+++ /trunk/wp-includes/version.php (revision 9296)
@@ -9,5 +9,5 @@
* @global string $wp_version
*/
-$wp_version = '2.7-almost-beta';
+$wp_version = '2.7-almost-beta-9296';
/**
@@ -16,5 +16,5 @@
* @global int $wp_db_version
*/
-$wp_db_version = 9290;
+$wp_db_version = 9296;
?>