Changeset 15572
- Timestamp:
- 09/05/2010 05:07:36 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/default-list-tables.php
r15571 r15572 2778 2778 2779 2779 function prepare_items() { 2780 global $s, $mode, $wpdb; 2781 2782 $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; 2783 2784 $per_page = $this->get_items_per_page( 'ms_users_per_page' ); 2785 2786 $pagenum = $this->get_pagenum(); 2787 2788 $s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : ''; 2789 $like_s = esc_sql( like_escape( $s ) ); 2790 2791 $query = "SELECT * FROM {$wpdb->users}"; 2792 2793 if ( !empty( $like_s ) ) { 2794 $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'"; 2795 } 2796 2797 $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : 'id'; 2798 if ( $order_by == 'email' ) { 2799 $query .= ' ORDER BY user_email '; 2800 } elseif ( $order_by == 'login' ) { 2801 $query .= ' ORDER BY user_login '; 2802 } elseif ( $order_by == 'name' ) { 2803 $query .= ' ORDER BY display_name '; 2804 } elseif ( $order_by == 'registered' ) { 2805 $query .= ' ORDER BY user_registered '; 2806 } else { 2807 $order_by = 'id'; 2808 $query .= ' ORDER BY ID '; 2809 } 2810 2811 $order = ( isset( $_REQUEST['order'] ) && 'DESC' == strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC'; 2812 $query .= $order; 2813 2814 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( ID )', $query ) ); 2815 2816 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page ); 2817 2818 $this->items = $wpdb->get_results( $query, ARRAY_A ); 2819 2820 $num_pages = ceil( $total / $per_page ); 2821 2780 $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; 2781 2782 $users_per_page = $this->get_items_per_page( 'ms_users_per_page' ); 2783 2784 $paged = $this->get_pagenum(); 2785 2786 $args = array( 2787 'number' => $users_per_page, 2788 'offset' => ( $paged-1 ) * $users_per_page, 2789 'search' => $usersearch, 2790 'blog_id' => 0 2791 ); 2792 2793 if ( isset( $_REQUEST['orderby'] ) ) 2794 $args['orderby'] = $_REQUEST['orderby']; 2795 2796 if ( isset( $_REQUEST['order'] ) ) 2797 $args['order'] = $_REQUEST['order']; 2798 2799 // Query the user IDs for this page 2800 $wp_user_search = new WP_User_Query( $args ); 2801 2802 $this->items = $wp_user_search->get_results(); 2803 2822 2804 $this->set_pagination_args( array( 2823 'total_items' => $ total,2824 'per_page' => $ per_page,2805 'total_items' => $wp_user_search->get_total(), 2806 'per_page' => $users_per_page, 2825 2807 ) ); 2826 2808 } … … 2883 2865 2884 2866 foreach ( $status_list as $status => $col ) { 2885 if ( $user [$status])2867 if ( $user->$status ) 2886 2868 $class = $col; 2887 2869 } … … 2897 2879 case 'cb': ?> 2898 2880 <th scope="row" class="check-column"> 2899 <input type="checkbox" id="blog_<?php echo $user ['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID']) ?>" />2881 <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" /> 2900 2882 </th> 2901 2883 <?php … … 2904 2886 case 'id': ?> 2905 2887 <th valign="top" scope="row"> 2906 <?php echo $user ['ID']?>2888 <?php echo $user->ID ?> 2907 2889 </th> 2908 2890 <?php … … 2910 2892 2911 2893 case 'login': 2912 $avatar = get_avatar( $user ['user_email'], 32 );2913 $edit_link = ( get_current_user_id() == $user ['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID'];2894 $avatar = get_avatar( $user->user_email, 32 ); 2895 $edit_link = ( get_current_user_id() == $user->ID ) ? 'profile.php' : 'user-edit.php?user_id=' . $user->ID; 2914 2896 ?> 2915 2897 <td class="username column-username"> 2916 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user ['user_login']); ?></a><?php2917 if ( in_array( $user ['user_login'], $super_admins ) )2898 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user->user_login ); ?></a><?php 2899 if ( in_array( $user->user_login, $super_admins ) ) 2918 2900 echo ' - ' . __( 'Super admin' ); 2919 2901 ?></strong> … … 2923 2905 $actions['edit'] = '<a href="' . esc_url( admin_url( $edit_link ) ) . '">' . __( 'Edit' ) . '</a>'; 2924 2906 2925 if ( ! in_array( $user ['user_login'], $super_admins ) ) {2926 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user ['ID']) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';2907 if ( ! in_array( $user->user_login, $super_admins ) ) { 2908 $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>'; 2927 2909 } 2928 2910 … … 2935 2917 2936 2918 case 'name': ?> 2937 <td class="name column-name"><?php echo $user ['display_name']?></td>2919 <td class="name column-name"><?php echo $user->display_name ?></td> 2938 2920 <?php 2939 2921 break; 2940 2922 2941 2923 case 'email': ?> 2942 <td class="email column-email"><a href="mailto:<?php echo $user ['user_email'] ?>"><?php echo $user['user_email']?></a></td>2924 <td class="email column-email"><a href="mailto:<?php echo $user->user_email ?>"><?php echo $user->user_email ?></a></td> 2943 2925 <?php 2944 2926 break; … … 2950 2932 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 2951 2933 ?> 2952 <td><?php echo mysql2date( __( $date ), $user ['user_registered']); ?></td>2934 <td><?php echo mysql2date( __( $date ), $user->user_registered ); ?></td> 2953 2935 <?php 2954 2936 break; 2955 2937 2956 2938 case 'blogs': 2957 $blogs = get_blogs_of_user( $user ['ID'], true );2939 $blogs = get_blogs_of_user( $user->ID, true ); 2958 2940 ?> 2959 2941 <td> … … 2983 2965 2984 2966 default: ?> 2985 <td><?php do_action( 'manage_users_custom_column', $column_name, $user ['ID']); ?></td>2967 <td><?php do_action( 'manage_users_custom_column', $column_name, $user->ID ); ?></td> 2986 2968 <?php 2987 2969 break;
Note: See TracChangeset
for help on using the changeset viewer.