Ticket #26564: 26564.2.diff
File 26564.2.diff, 5.5 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
9 9 */ 10 10 class WP_Users_List_Table extends WP_List_Table { 11 11 12 /** 13 * The site ID that WP_Users_List_Table is being generated for. 14 * 15 * @since 3.1.0 16 * @access public 17 * @var int $site_id The site ID. 18 */ 12 19 var $site_id; 20 21 /** 22 * Whether the WP_Users_List_Table instance is being generated for 23 * the Multisite users page or not. True for Multisite. 24 * 25 * @since 3.1.0 26 * @access public 27 * 28 * @var bool $is_site_users 29 */ 13 30 var $is_site_users; 14 31 32 /** 33 * Constructor. 34 * 35 * @since 3.1.0 36 * @access public 37 * 38 * @see WP_List_Table::__construct() 39 */ 15 40 function __construct( $args = array() ) { 16 41 parent::__construct( array( 17 42 'singular' => 'user', … … 25 50 $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; 26 51 } 27 52 53 /** 54 * Check the current user's permissions. 55 * 56 * @since 3.1.0 57 * @access public 58 * 59 * @see WP_List_Table::__construct() 60 */ 28 61 function ajax_user_can() { 29 62 if ( $this->is_site_users ) 30 63 return current_user_can( 'manage_sites' ); … … 32 65 return current_user_can( 'list_users' ); 33 66 } 34 67 68 /** 69 * Prepare the list of users for display. 70 * 71 * @since 3.1.0 72 * @access public 73 * 74 * @see WP_List_Table::prepare_items() 75 */ 35 76 function prepare_items() { 36 77 global $role, $usersearch; 37 78 … … 75 116 ) ); 76 117 } 77 118 119 /** 120 * Output 'no users' message. 121 * 122 * @since 3.1.0 123 * @access public 124 * 125 * @see WP_List_Table::no_items() 126 */ 78 127 function no_items() { 79 128 _e( 'No matching users were found.' ); 80 129 } 81 130 131 /** 132 * Return an associative array listing all the views that can be used 133 * with this table. 134 * 135 * Provides a list of roles, and user count for that role for easy 136 * filter of the user table. 137 * 138 * @since 3.1.0 139 * @access public 140 * 141 * @see WP_List_Table::get_views() 142 * 143 * @return array An array of HTML links, one for each view. 144 */ 82 145 function get_views() { 83 146 global $wp_roles, $role; 84 147 … … 119 182 return $role_links; 120 183 } 121 184 185 /** 186 * Get an associative array of bulk actions available on this table. 187 * 188 * @since 3.1.0 189 * @access public 190 * 191 * @see WP_List_Table::get_bulk_actions() 192 * 193 * @return array Array of bulk actions. 194 */ 122 195 function get_bulk_actions() { 123 196 $actions = array(); 124 197 … … 133 206 return $actions; 134 207 } 135 208 209 /** 210 * Output the controls to allow user roles to be changed in bulk. 211 * 212 * @since 3.1.0 213 * @access public 214 * 215 * @see WP_List_Table::extra_tablenav() 216 * 217 * @param string $which Whether this is being invoked above ("top") 218 * or below the table ("bottom"). 219 */ 136 220 function extra_tablenav( $which ) { 137 221 if ( 'top' != $which ) 138 222 return; … … 152 236 echo '</div>'; 153 237 } 154 238 239 /** 240 * Capture the bulk action required, and return it. 241 * 242 * Overriden from the base class implementation to capture 243 * the role change drop-down. 244 * 245 * @since 3.1.0 246 * @access public 247 * 248 * @see WP_List_Table::current_action() 249 * 250 * @return string The bulk action required. 251 */ 155 252 function current_action() { 156 253 if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) ) 157 254 return 'promote'; … … 159 256 return parent::current_action(); 160 257 } 161 258 259 /** 260 * Get a list of columns for the list table. 261 * 262 * @since 3.1.0 263 * @access public 264 * 265 * @see WP_List_Table::get_columns() 266 * 267 * @return array Array in which the key is the ID of the column, 268 * and the value is the description. 269 */ 162 270 function get_columns() { 163 271 $c = array( 164 272 'cb' => '<input type="checkbox" />', … … 175 283 return $c; 176 284 } 177 285 286 /** 287 * Get a list of sortable columns for the list table. 288 * 289 * @since 3.1.0 290 * @access public 291 * 292 * @see WP_List_Table::get_sortable_columns() 293 * 294 * @return array Array of sortable columns. 295 */ 178 296 function get_sortable_columns() { 179 297 $c = array( 180 298 'username' => 'login', … … 188 306 return $c; 189 307 } 190 308 309 /** 310 * Generate the list table rows. 311 * 312 * @since 3.1.0 313 * @access public 314 * 315 * @see WP_List_Table::display_rows() 316 */ 191 317 function display_rows() { 192 318 // Query the post counts for this page 193 319 if ( ! $this->is_site_users ) … … 216 342 /** 217 343 * Generate HTML for a single row on the users.php admin panel. 218 344 * 219 * @since 2.1.0 345 * @since 3.1.0 346 * @access public 220 347 * 221 * @param object $user_object 222 * @param string $style Optional. Attributes added to the TR element. Must be sanitized. 223 * @param string $role Key for the $wp_roles array. 224 * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts. 225 * @return string 348 * @param object $user_object The current user object. 349 * @param string $style Optional. Style attributes added to the <tr> element. 350 * Must be sanitized. Default empty. 351 * @param string $role Optional. Key for the $wp_roles array. Default empty. 352 * @param int $numposts Optional. Post count to display for this user. Defaults 353 * to zero, as in, a new user has made zero posts. 354 * @return string Output for a single row. 226 355 */ 227 356 function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { 228 357 global $wp_roles;