WordPress.org

Make WordPress Core

Ticket #2793: alpha.diff

File alpha.diff, 4.3 KB (added by filosofo, 9 years ago)

Adds alphabetizing feature to the paging

  • wp-admin/users.php

     
    3030        var $search_term; 
    3131        var $page; 
    3232        var $raw_page; 
     33        var $letter_search; 
    3334        var $users_per_page = 50; 
    3435        var $first_user; 
    3536        var $last_user; 
     
    3940        var $too_many_total_users = false; 
    4041        var $search_errors; 
    4142 
    42         function WP_User_Search ($search_term = '', $page = '') { // constructor 
     43        function WP_User_Search ($search_term = '', $page = '', $letter = '') { // constructor 
    4344                $this->search_term = $search_term; 
    4445                $this->raw_page = ( '' == $page ) ? false : (int) $page; 
    4546                $this->page = (int) ( '' == $page ) ? 1 : $page; 
     47                $this->letter_search = ( '' == $letter ) ? "" : " AND user_login LIKE '$letter%'"; 
    4648 
    4749                $this->prepare_query(); 
    4850                $this->query(); 
     
    6264                        $search_sql .= implode(' OR ', $searches); 
    6365                        $search_sql .= ')'; 
    6466                } 
    65                 $this->query_from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; 
     67                $this->query_from_where = "FROM $wpdb->users WHERE 1=1 $search_sql $this->letter_search"; 
    6668 
    6769                if ( !$_GET['update'] && !$this->search_term && !$this->raw_page && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $this->users_per_page ) 
    6870                        $this->too_many_total_users = sprintf(__('Because this blog has more than %s users, they cannot all be shown on one page.  Use the paging or search functionality in order to find the user you want to edit.'), $this->users_per_page); 
     
    8890                        $next_page = ( ($this->page * $this->users_per_page) < $this->total_users_for_query ) ? true : false; 
    8991                        $this->paging_text = ''; 
    9092                        if ( $prev_page ) 
    91                                 $this->paging_text .= '<p class="alignleft"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page - 1), 'users.php?') . '">&laquo; Previous Page</a></p>'; 
     93                                $this->paging_text .= '<p class="alignleft"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page - 1, 'userletter' => $_GET['userletter']), 'users.php?') . '">&laquo; Previous Page</a></p>'; 
    9294                        if ( $next_page ) 
    93                                 $this->paging_text .= '<p class="alignright"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page + 1), 'users.php?') . '">Next Page &raquo;</a></p>'; 
     95                                $this->paging_text .= '<p class="alignright"><a href="' . add_query_arg(array('usersearch' => $this->search_term, 'userspage' => $this->page + 1, 'userletter' => $_GET['userletter']), 'users.php?') . '">Next Page &raquo;</a></p>'; 
    9496                        if ( $prev_page || $next_page ) 
    9597                                $this->paging_text .= '<br style="clear:both" />'; 
    9698                } 
     
    271273        include('admin-header.php'); 
    272274 
    273275        // Query the users 
    274         $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']); 
     276        $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage'], $_GET['userletter']); 
    275277 
    276278        // Make the user objects 
    277279        foreach ( $wp_user_search->get_results() as $userid ) { 
     
    333335<?php endif; ?> 
    334336 
    335337<div class="wrap"> 
     338        <?php  
     339        for ( $i=65; $i<=90; $i++ ) $user_alphabet[] = chr($i); 
     340        $user_alphabet = apply_filters('user_alphabet', $user_alphabet); 
     341        foreach ( $user_alphabet as $letter ) { 
     342                $alpha_list .= ( $_GET['userletter'] == $letter ) ?  
     343                        "<li class='current'><a href='users.php?userletter=$letter'><strong>$letter</strong></a></li>\n"  
     344                        :  "<li><a href='users.php?userletter=$letter'>$letter</a></li>\n"; 
     345        } 
     346        ?><ul id='user_alphabet'> 
     347        <?php echo $alpha_list; ?> 
     348        </ul> 
    336349 
    337350        <?php if ( $wp_user_search->is_search() ) : ?> 
    338351                <h2><?php printf(__('Users Matching "%s" by Role'), $wp_user_search->search_term); ?></h2> 
     
    507520} // end of the $action switch 
    508521 
    509522include('admin-footer.php'); 
    510 ?> 
    511  No newline at end of file 
     523?> 
  • wp-admin/wp-admin.css

     
    417417        color: #333; 
    418418} 
    419419 
    420 #adminmenu li, #submenu li { 
     420#adminmenu li, #submenu li, #user_alphabet li { 
    421421        display: inline; 
    422422        line-height: 200%; 
    423423        list-style: none; 
    424424        text-align: center; 
    425425} 
    426426 
     427#user_alphabet { 
     428        text-align: center; 
     429} 
     430 
     431#user_alphabet li { 
     432        padding: .3em; 
     433        text-align: center; 
     434        font-size: 120%; 
     435} 
     436 
    427437#submenu { 
    428438        background: #0d324f; 
    429439        border-bottom: none;