Make WordPress Core

Ticket #26564: 26564.2.diff

File 26564.2.diff, 5.5 KB (added by DrewAPicture, 11 years ago)

2nd pass

  • src/wp-admin/includes/class-wp-users-list-table.php

     
    99 */
    1010class WP_Users_List_Table extends WP_List_Table {
    1111
     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         */
    1219        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         */
    1330        var $is_site_users;
    1431
     32        /**
     33         * Constructor.
     34         *
     35         * @since 3.1.0
     36         * @access public
     37         *
     38         * @see WP_List_Table::__construct()
     39         */
    1540        function __construct( $args = array() ) {
    1641                parent::__construct( array(
    1742                        'singular' => 'user',
     
    2550                        $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    2651        }
    2752
     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         */
    2861        function ajax_user_can() {
    2962                if ( $this->is_site_users )
    3063                        return current_user_can( 'manage_sites' );
     
    3265                        return current_user_can( 'list_users' );
    3366        }
    3467
     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         */
    3576        function prepare_items() {
    3677                global $role, $usersearch;
    3778
     
    75116                ) );
    76117        }
    77118
     119        /**
     120         * Output 'no users' message.
     121         *
     122         * @since 3.1.0
     123         * @access public
     124         *
     125         * @see WP_List_Table::no_items()
     126         */
    78127        function no_items() {
    79128                _e( 'No matching users were found.' );
    80129        }
    81130
     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         */
    82145        function get_views() {
    83146                global $wp_roles, $role;
    84147
     
    119182                return $role_links;
    120183        }
    121184
     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         */
    122195        function get_bulk_actions() {
    123196                $actions = array();
    124197
     
    133206                return $actions;
    134207        }
    135208
     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         */
    136220        function extra_tablenav( $which ) {
    137221                if ( 'top' != $which )
    138222                        return;
     
    152236                echo '</div>';
    153237        }
    154238
     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         */
    155252        function current_action() {
    156253                if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
    157254                        return 'promote';
     
    159256                return parent::current_action();
    160257        }
    161258
     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         */
    162270        function get_columns() {
    163271                $c = array(
    164272                        'cb'       => '<input type="checkbox" />',
     
    175283                return $c;
    176284        }
    177285
     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         */
    178296        function get_sortable_columns() {
    179297                $c = array(
    180298                        'username' => 'login',
     
    188306                return $c;
    189307        }
    190308
     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         */
    191317        function display_rows() {
    192318                // Query the post counts for this page
    193319                if ( ! $this->is_site_users )
     
    216342        /**
    217343         * Generate HTML for a single row on the users.php admin panel.
    218344         *
    219          * @since 2.1.0
     345         * @since 3.1.0
     346         * @access public
    220347         *
    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.
    226355         */
    227356        function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
    228357                global $wp_roles;