Ticket #2785: 2785.patch
| File 2785.patch, 3.6 KB (added by , 11 years ago) |
|---|
-
includes/common/classes.php
367 367 // Get element's id 368 368 $id_field = $this->db_fields['id']; 369 369 $id = $element->$id_field; 370 371 // Now fetch child replies for each reply as they're listed... 372 $reply_search = !empty($_REQUEST['rs']) ? $_REQUEST['rs'] : false; 373 $post_type = (bbp_is_single_topic() && bbp_show_lead_topic()) ? bbp_get_reply_post_type() : array(bbp_get_topic_post_type(), bbp_get_reply_post_type()); 370 374 375 $child_args = array( 376 'post_type' => $post_type, 377 'post_parent' => bbp_get_topic_id(), 378 'posts_per_page' => '-1', 379 'orderby' => 'date', 380 'order' => 'ASC', 381 'hierarchical' => true, 382 'ignore_sticky_posts' => true, 383 's' => $reply_search, 384 'meta_query' => array(array( 385 'key' => '_bbp_reply_to', 386 'compare' => '=', 387 'value' => $id 388 )) 389 ); 390 391 $parsed_args = bbp_parse_args('', $child_args, 'has_replies'); 392 $child_posts = new WP_Query($parsed_args); 393 $children_elements = array($id => $child_posts->posts); 394 wp_reset_postdata(); 395 371 396 // Display element 372 397 parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); 373 398 … … 538 563 } 539 564 } 540 565 endif; // class_exists check 566 567 ?> 568 No newline at end of file -
includes/replies/template.php
139 139 'hierarchical' => $default_thread_replies, // Hierarchical replies 140 140 'ignore_sticky_posts' => true, // Stickies not supported 141 141 ); 142 143 // Suppress threaded replies for now... 144 if (bbp_thread_replies()) { 145 $default['meta_query'] = array('relation' => 'OR', 146 array( 147 'key' => '_bbp_reply_to', 148 'compare' => 'NOT EXISTS', 149 'value' => '0' 150 ), 151 array( 152 'key' => '_bbp_reply_to', 153 'compare' => '=', 154 'value' => '0' 155 ) 156 ); 157 } 142 158 143 159 // Only add 's' arg if searching for replies 144 160 // See https://bbpress.trac.wordpress.org/ticket/2607 … … 178 194 179 195 // Set posts_per_page value if replies are threaded 180 196 $replies_per_page = $r['posts_per_page']; 181 if ( true === $r['hierarchical'] ) {182 $r['posts_per_page'] = -1;183 }184 197 185 198 // Get bbPress 186 199 $bbp = bbpress(); … … 252 265 } 253 266 254 267 // Figure out total pages 255 if ( true === $r['hierarchical'] ) { 256 $walker = new BBP_Walker_Reply; 257 $total_pages = ceil( (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) / (int) $replies_per_page ); 258 } else { 268 259 269 $total_pages = ceil( (int) $bbp->reply_query->found_posts / (int) $replies_per_page ); 260 270 261 271 // Add pagination to query object … … 276 286 } else { 277 287 $bbp->reply_query->pagination_links = str_replace( '&paged=1', '', $bbp->reply_query->pagination_links ); 278 288 } 279 } 289 280 290 } 281 291 282 292 // Return object … … 2461 2471 2462 2472 // We are threading replies 2463 2473 if ( bbp_thread_replies() && bbp_is_single_topic() ) { 2464 return; 2474 2465 2475 $walker = new BBP_Walker_Reply; 2466 $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) ;2476 $threads = (int) $walker->get_number_of_root_elements( $bbp->reply_query->posts ) + 1; // Not sure where this OB1 error comes from... 2467 2477 2468 2478 // Adjust for topic 2469 2479 $threads--; … … 2872 2882 2873 2883 return false; 2874 2884 } 2885 2886 ?> 2887 No newline at end of file