Ticket #483: blog-pagination.diff
| File blog-pagination.diff, 4.2 kB (added by ktlee, 10 months ago) |
|---|
-
wp-admin/wpmu-blogs.php
old new 280 280 281 281 // List blogs 282 282 default: 283 $ start = isset( $_GET['start'] ) ? intval( $_GET['start'] ) : 0;284 $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 60;283 $apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1; 284 $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 30; 285 285 286 286 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 287 287 … … 308 308 if( isset( $_GET['sortby'] ) == false ) { 309 309 $_GET['sortby'] = 'id'; 310 310 } 311 311 312 if( $_GET['sortby'] == 'registered' ) { 312 313 $query .= ' ORDER BY registered '; 313 314 } elseif( $_GET['sortby'] == 'id' ) { … … 321 322 $query .= ( $_GET['order'] == 'DESC' ) ? 'DESC' : 'ASC'; 322 323 323 324 if ( $_GET['ip_address'] == '' ) 324 $query .= " LIMIT " . intval( $start) . ", " . intval( $num );325 $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num ); 325 326 326 327 $blog_list = $wpdb->get_results( $query, ARRAY_A ); 327 328 328 $next = ( count( $blog_list ) < $num ) ? false : true; 329 330 // Pagination 331 $url2 = "order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; 332 $blog_navigation = ''; 333 if( $start == 0 ) { 334 $blog_navigation .= __('Previous Blogs'); 335 } elseif( $start <= 30 ) { 336 $blog_navigation .= '<a href="wpmu-blogs.php?start=0&' . $url2 . ' ">' . __('Previous Blogs') . '</a>'; 329 if( !empty($_GET['s']) || !empty($_GET['blog_id']) || !empty($_GET['ip_address'])) { 330 $total = count($blog_list); 337 331 } else { 338 $blog_navigation .= '<a href="wpmu-blogs.php?start=' . ( $start - $num ) . '&' . $url2 . '">' . __('Previous Blogs') . '</a>'; 339 } 340 if ( $next ) { 341 $blog_navigation .= ' || <a href="wpmu-blogs.php?start=' . ( $start + $num ) . '&' . $url2 . '">' . __('Next Blogs') . '</a>'; 342 } else { 343 $blog_navigation .= ' || ' . __('Next Blogs'); 332 $total = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "); 344 333 } 334 335 // Pagination 336 $url2 = "&order=" . $_GET['order'] . "&sortby=" . $_GET['sortby'] . "&s=" . $_GET['s'] . "&ip_address=" . $_GET['ip_address']; 337 $blog_navigation = paginate_links( array( 338 'base' => add_query_arg( 'apage', '%#%' ).$url2, 339 'format' => '', 340 'total' => ceil($total / $num), 341 'current' => $apage 342 )); 345 343 ?> 346 344 <script type="text/javascript"> 347 345 <!-- … … 377 375 <div class="wrap"> 378 376 <h2><?php _e('Blogs') ?></h2> 379 377 <div style="float:right; padding:0 20px; margin-top:20px;"> 380 <h4 style="margin:0 0 4px;"><?php _e('Blog Navigation') ?></h4> 381 <?php echo $blog_navigation; ?> 378 <?php if ( $blog_navigation ) echo "<p class='pagenav'>$blog_navigation</p>"; ?> 382 379 </div> 383 380 384 381 <form id="searchform" action="wpmu-blogs.php" method="get"> … … 437 434 <thead> 438 435 <tr> 439 436 <?php foreach($posts_columns as $column_id => $column_display_name) : ?> 440 <th scope="col"><a href="wpmu-blogs.php?<?php echo $sortby_url ?>&sortby=<?php echo $column_id ?>&<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?> start=<?php echo $start?>"><?php echo $column_display_name; ?></a></th>437 <th scope="col"><a href="wpmu-blogs.php?<?php echo $sortby_url ?>&sortby=<?php echo $column_id ?>&<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&" ; } else { echo "order=DESC&"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a></th> 441 438 <?php endforeach ?> 442 439 </tr> 443 440 </thead> … … 595 592 </table> 596 593 597 594 <div style="float:right; padding:0 20px; margin-top:20px;"> 598 <h4 style="margin:0 0 4px;"><?php _e('Blog Navigation') ?></h4> 599 <?php echo $blog_navigation;?> 595 <?php if ( $blog_navigation ) echo "<p class='pagenav'>$blog_navigation</p>"; ?> 600 596 </div> 601 597 <input style="margin:5px 0;" id="check_all2" type="button" class="button" value="<?php _e('Check All') ?>" onclick="check_all_rows()" /> 602 598
