Changeset 6680 for trunk/src/includes/topics/template.php
- Timestamp:
- 09/07/2017 05:40:59 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/topics/template.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/topics/template.php
r6644 r6680 203 203 // Limited the number of pages shown 204 204 if ( ! empty( $r['max_num_pages'] ) ) { 205 $bbp->topic_query->max_num_pages = $r['max_num_pages'];205 $bbp->topic_query->max_num_pages = (int) $r['max_num_pages']; 206 206 } 207 207 … … 223 223 224 224 // Only add pagination if query returned results 225 if ( ( (int) $bbp->topic_query->post_count || (int) $bbp->topic_query->found_posts ) && (int) $bbp->topic_query->posts_per_page) {225 if ( ( ! empty( $bbp->topic_query->post_count ) || ! empty( $bbp->topic_query->found_posts ) ) && ! empty( $bbp->topic_query->posts_per_page ) ) { 226 226 227 227 // Limit the number of topics shown based on maximum allowed pages … … 231 231 232 232 // Total topics for pagination boundaries 233 $total = ( $r['posts_per_page']=== $bbp->topic_query->found_posts )233 $total_pages = ( $bbp->topic_query->posts_per_page === $bbp->topic_query->found_posts ) 234 234 ? 1 235 : ceil( (int) $bbp->topic_query->found_posts / (int) $r['posts_per_page'] ); 235 : ceil( $bbp->topic_query->found_posts / $bbp->topic_query->posts_per_page ); 236 237 // Maybe add view-all args 238 $add_args = bbp_get_view_all() 239 ? array( 'view' => 'all' ) 240 : false; 236 241 237 242 // Pagination settings with filter … … 239 244 'base' => bbp_get_topics_pagination_base( $r['post_parent'] ), 240 245 'format' => '', 241 'total' => (int) $total,242 'current' => (int)$bbp->topic_query->paged,246 'total' => $total_pages, 247 'current' => $bbp->topic_query->paged, 243 248 'prev_text' => is_rtl() ? '→' : '←', 244 249 'next_text' => is_rtl() ? '←' : '→', 245 'mid_size' => 1 250 'mid_size' => 1, 251 'add_args' => $add_args, 246 252 ) ); 247 253 248 254 // Add pagination to query object 249 $bbp->topic_query->pagination_links = paginate_links( $bbp_topic_pagination ); 250 251 // Remove first page from pagination 252 $bbp->topic_query->pagination_links = str_replace( bbp_get_paged_slug() . "/1/'", "'", $bbp->topic_query->pagination_links ); 255 $bbp->topic_query->pagination_links = bbp_paginate_links( $bbp_topic_pagination ); 253 256 } 254 257 … … 781 784 782 785 // If pretty permalinks are enabled, make our pagination pretty 783 if ( bbp_use_pretty_urls() ) { 784 $base = trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ); 785 } else { 786 $base = add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); 787 } 786 $base = bbp_use_pretty_urls() 787 ? trailingslashit( get_permalink( $r['topic_id'] ) ) . user_trailingslashit( bbp_get_paged_slug() . '/%#%/' ) 788 : add_query_arg( 'paged', '%#%', get_permalink( $r['topic_id'] ) ); 788 789 789 790 // Get total and add 1 if topic is included in the reply loop … … 794 795 $total++; 795 796 } 797 798 // Total for pagination boundaries 799 $total_pages = ceil( $total / bbp_get_replies_per_page() ); 796 800 797 801 // Maybe add view-all args … … 800 804 : false; 801 805 802 // Add pagination to query object803 $ pagination_links = paginate_links(array(806 // Pagination settings with filter 807 $bbp_topic_pagination = apply_filters( 'bbp_get_topic_pagination', array( 804 808 'base' => $base, 805 'format' => '', 806 'total' => ceil( (int) $total / (int) bbp_get_replies_per_page() ), 809 'total' => $total_pages, 807 810 'current' => 0, 808 811 'prev_next' => false, 809 812 'mid_size' => 2, 810 'end_size' => 3,813 'end_size' => 2, 811 814 'add_args' => $add_args 812 815 ) ); 813 816 817 // Add pagination to query object 818 $pagination_links = bbp_paginate_links( $bbp_topic_pagination ); 819 820 // Maybe add before and after to pagination links 814 821 if ( ! empty( $pagination_links ) ) { 815 816 // Remove first page from pagination817 if ( bbp_use_pretty_urls() ) {818 $pagination_links = str_replace( bbp_get_paged_slug() . '/1/', '', $pagination_links );819 } else {820 $pagination_links = preg_replace( '/&paged=1(?=[^0-9])/m', '', $pagination_links );821 }822 823 // Add before and after to pagination links824 822 $pagination_links = $r['before'] . $pagination_links . $r['after']; 825 823 } … … 2913 2911 2914 2912 // Filter & return 2915 return apply_filters( 'bbp_get_topics_pagination_base', $base );2913 return apply_filters( 'bbp_get_topics_pagination_base', $base, $forum_id ); 2916 2914 } 2917 2915
Note: See TracChangeset
for help on using the changeset viewer.