Changeset 35331
- Timestamp:
- 10/21/2015 04:25:31 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/schema.php
r35312 r35331 483 483 'thread_comments' => 1, 484 484 'thread_comments_depth' => 5, 485 'page_comments' => 0, 485 486 'comments_per_page' => 50, 486 487 'default_comments_page' => 'newest', … … 568 569 'random_seed', 'rss_excerpt_length', 'secret', 'use_linksupdate', 'default_comment_status_page', 569 570 'wporg_popular_tags', 'what_to_show', 'rss_language', 'language', 'enable_xmlrpc', 'enable_app', 570 'embed_autourls', 'default_post_edit_rows', 'page_comments',571 'embed_autourls', 'default_post_edit_rows', 571 572 ); 572 573 foreach ( $unusedoptions as $option ) -
trunk/src/wp-admin/options-discussion.php
r34726 r35331 99 99 ?></label> 100 100 <br /> 101 <label for="page_comments"> 102 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> /> 101 103 <?php 102 104 $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"'; … … 106 108 $default_comments_page .= '>' . __('first') . '</option></select>'; 107 109 108 printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '< label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );110 printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page ); 109 111 110 112 ?></label> -
trunk/src/wp-admin/options.php
r34912 r35331 84 84 $whitelist_options = array( 85 85 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ), 86 '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', ' comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ),86 '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' ), 87 87 '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' ), 88 88 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ), -
trunk/src/wp-includes/canonical.php
r35170 r35331 319 319 } 320 320 321 if ( ( 'newest' == get_option('default_comments_page') && get_query_var('cpage') > 0 ) || ( 'newest' != get_option('default_comments_page') && get_query_var('cpage') > 1 ) ) { 321 if ( get_option( 'page_comments' ) && ( 322 ( 'newest' == get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 0 ) || 323 ( 'newest' != get_option( 'default_comments_page' ) && get_query_var( 'cpage' ) > 1 ) 324 ) ) { 322 325 $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' ); 323 326 $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); -
trunk/src/wp-includes/comment-functions.php
r35170 r35331 808 808 return 0; 809 809 810 if ( ! get_option( 'page_comments' ) ) { 811 return 1; 812 } 813 810 814 if ( !isset($per_page) ) 811 815 $per_page = (int) get_query_var('comments_per_page'); … … 861 865 862 866 // Order of precedence: 1. `$args['per_page']`, 2. 'comments_per_page' query_var, 3. 'comments_per_page' option. 863 if ( '' === $args['per_page'] ) { 864 $args['per_page'] = get_query_var( 'comments_per_page' ); 865 } 866 867 if ( '' === $args['per_page'] ) { 868 $args['per_page'] = get_option( 'comments_per_page' ); 867 if ( get_option( 'page_comments' ) ) { 868 if ( '' === $args['per_page'] ) { 869 $args['per_page'] = get_query_var( 'comments_per_page' ); 870 } 871 872 if ( '' === $args['per_page'] ) { 873 $args['per_page'] = get_option( 'comments_per_page' ); 874 } 869 875 } 870 876 -
trunk/src/wp-includes/comment-template.php
r35013 r35331 707 707 // No 'cpage' is provided, so we calculate one. 708 708 } else { 709 if ( '' === $args['per_page'] ) {709 if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { 710 710 $args['per_page'] = get_option('comments_per_page'); 711 711 } … … 1269 1269 $comment_args = array( 1270 1270 'orderby' => 'comment_date_gmt', 1271 'order' => 'ASC', 1271 1272 'status' => 'approve', 1272 1273 'post_id' => $post->ID, … … 1282 1283 } 1283 1284 1284 $per_page = (int) get_query_var( 'comments_per_page' ); 1285 if ( 0 === $per_page ) { 1286 $per_page = (int) get_option( 'comments_per_page' ); 1287 } 1288 1289 $comment_args['order'] = 'ASC'; 1290 $comment_args['number'] = $per_page; 1291 $page = (int) get_query_var( 'cpage' ); 1292 1293 if ( $page ) { 1294 $comment_args['offset'] = ( $page - 1 ) * $per_page; 1295 } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { 1296 $comment_args['offset'] = 0; 1297 } else { 1298 // If fetching the first page of 'newest', we need a top-level comment count. 1299 $top_level_query = new WP_Comment_Query(); 1300 $top_level_count = $top_level_query->query( array( 1301 'count' => true, 1302 'orderby' => false, 1303 'post_id' => $post->ID, 1304 'parent' => 0, 1305 ) ); 1306 1307 $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; 1285 $per_page = 0; 1286 if ( get_option( 'page_comments' ) ) { 1287 $per_page = (int) get_query_var( 'comments_per_page' ); 1288 if ( 0 === $per_page ) { 1289 $per_page = (int) get_option( 'comments_per_page' ); 1290 } 1291 1292 $comment_args['number'] = $per_page; 1293 $page = (int) get_query_var( 'cpage' ); 1294 1295 if ( $page ) { 1296 $comment_args['offset'] = ( $page - 1 ) * $per_page; 1297 } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { 1298 $comment_args['offset'] = 0; 1299 } else { 1300 // If fetching the first page of 'newest', we need a top-level comment count. 1301 $top_level_query = new WP_Comment_Query(); 1302 $top_level_count = $top_level_query->query( array( 1303 'count' => true, 1304 'orderby' => false, 1305 'post_id' => $post->ID, 1306 'parent' => 0, 1307 ) ); 1308 1309 $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page; 1310 } 1308 1311 } 1309 1312 … … 1346 1349 1347 1350 $overridden_cpage = false; 1348 if ( '' == get_query_var( 'cpage')) {1351 if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { 1349 1352 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); 1350 1353 $overridden_cpage = true; … … 1942 1945 } 1943 1946 1944 if ( '' === $r['per_page'] )1947 if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { 1945 1948 $r['per_page'] = get_query_var('comments_per_page'); 1949 } 1946 1950 1947 1951 if ( empty($r['per_page']) ) { -
trunk/src/wp-includes/default-filters.php
r35253 r35331 330 330 add_filter( 'default_option_embed_autourls', '__return_true' ); 331 331 332 // This option no longer exists; tell plugins we want comment pagination.333 add_filter( 'pre_option_page_comments', '__return_true' );334 335 332 // Default settings for heartbeat 336 333 add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' ); -
trunk/src/wp-includes/version.php
r35306 r35331 12 12 * @global int $wp_db_version 13 13 */ 14 $wp_db_version = 3 4978;14 $wp_db_version = 35329; 15 15 16 16 /** -
trunk/tests/phpunit/tests/comment/commentsTemplate.php
r35242 r35331 167 167 update_option( 'comment_order', 'asc' ); 168 168 update_option( 'default_comments_page', 'newest' ); 169 update_option( 'page_comments', '1' ); 169 170 170 171 $link = add_query_arg( array( … … 222 223 update_option( 'comment_order', 'desc' ); 223 224 update_option( 'default_comments_page', 'newest' ); 225 update_option( 'page_comments', '1' ); 224 226 225 227 $link = add_query_arg( array( … … 267 269 update_option( 'comment_order', 'asc' ); 268 270 update_option( 'default_comments_page', 'oldest' ); 271 update_option( 'page_comments', '1' ); 269 272 270 273 $link = add_query_arg( array( … … 312 315 update_option( 'comment_order', 'desc' ); 313 316 update_option( 'default_comments_page', 'oldest' ); 317 update_option( 'page_comments', '1' ); 314 318 315 319 $link = add_query_arg( array( … … 354 358 update_option( 'default_comments_page', 'newest' ); 355 359 update_option( 'comment_order', 'desc' ); 360 update_option( 'page_comments', '1' ); 356 361 357 362 $link = add_query_arg( array( … … 396 401 update_option( 'default_comments_page', 'newest' ); 397 402 update_option( 'comment_order', 'desc' ); 403 update_option( 'page_comments', '1' ); 398 404 399 405 $link = add_query_arg( array( … … 441 447 update_option( 'comment_order', 'desc' ); 442 448 update_option( 'default_comments_page', 'oldest' ); 449 update_option( 'page_comments', '1' ); 443 450 444 451 $link_p1 = add_query_arg( array( … … 515 522 update_option( 'comment_order', 'desc' ); 516 523 update_option( 'default_comments_page', 'newest' ); 524 update_option( 'page_comments', '1' ); 517 525 518 526 $link_p0 = add_query_arg( array( -
trunk/tests/phpunit/tests/comment/getCommentLink.php
r35242 r35331 49 49 */ 50 50 public function test_default_comments_page_newest_default_page_should_have_cpage() { 51 update_option( 'page_comments', 1 ); 51 52 update_option( 'default_comments_page', 'newest' ); 52 53 update_option( 'comments_per_page', 2 ); … … 61 62 */ 62 63 public function test_default_comments_page_newest_middle_page_should_have_cpage() { 64 update_option( 'page_comments', 1 ); 63 65 update_option( 'default_comments_page', 'newest' ); 64 66 update_option( 'comments_per_page', 2 ); … … 73 75 */ 74 76 public function test_default_comments_page_newest_last_page_should_have_cpage() { 77 update_option( 'page_comments', 1 ); 75 78 update_option( 'default_comments_page', 'newest' ); 76 79 update_option( 'comments_per_page', 2 ); … … 97 100 */ 98 101 public function test_default_comments_page_oldest_middle_page_should_have_cpage() { 102 update_option( 'page_comments', 1 ); 99 103 update_option( 'default_comments_page', 'oldest' ); 100 104 update_option( 'comments_per_page', 2 ); … … 109 113 */ 110 114 public function test_default_comments_page_oldest_last_page_should_have_cpage() { 115 update_option( 'page_comments', 1 ); 111 116 update_option( 'default_comments_page', 'oldest' ); 112 117 update_option( 'comments_per_page', 2 ); -
trunk/tests/phpunit/tests/comment/getPageOfComment.php
r35242 r35331 234 234 $c3 = self::factory()->comment->create( array( 'comment_post_ID' => $p, 'comment_date_gmt' => date( 'Y-m-d H:i:s', $now - 30 ) ) ); 235 235 236 update_option( 'page_comments', 1 ); 236 237 update_option( 'comments_per_page', 2 ); 237 238
Note: See TracChangeset
for help on using the changeset viewer.