]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-ms-users-list-table.php
WordPress 4.2
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-ms-users-list-table.php
index 6a4268f6ae80a8fe48a164c2e720a8b2dfbc4f85..e5eaeb5056185455a100d7f0ee1a7930607eedb7 100644 (file)
@@ -9,14 +9,14 @@
  */
 class WP_MS_Users_List_Table extends WP_List_Table {
 
-       function ajax_user_can() {
+       public function ajax_user_can() {
                return current_user_can( 'manage_network_users' );
        }
 
-       function prepare_items() {
+       public function prepare_items() {
                global $usersearch, $role, $wpdb, $mode;
 
-               $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
+               $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
 
                $users_per_page = $this->get_items_per_page( 'users_network_per_page' );
 
@@ -40,8 +40,11 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                        $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
                }
 
-               // If the network is large and a search is not being performed, show only the latest users with no paging in order
-               // to avoid expensive count queries.
+               /*
+                * If the network is large and a search is not being performed,
+                * show only the latest users with no paging in order to avoid
+                * expensive count queries.
+                */
                if ( !$usersearch && wp_is_large_network( 'users' ) ) {
                        if ( !isset($_REQUEST['orderby']) )
                                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
@@ -69,7 +72,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                ) );
        }
 
-       function get_bulk_actions() {
+       protected function get_bulk_actions() {
                $actions = array();
                if ( current_user_can( 'delete_users' ) )
                        $actions['delete'] = __( 'Delete' );
@@ -79,18 +82,17 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                return $actions;
        }
 
-       function no_items() {
+       public function no_items() {
                _e( 'No users found.' );
        }
 
-       function get_views() {
-               global $wp_roles, $role;
+       protected function get_views() {
+               global $role;
 
                $total_users = get_user_count();
                $super_admins = get_super_admins();
                $total_admins = count( $super_admins );
 
-               $current_role = false;
                $class = $role != 'super' ? ' class="current"' : '';
                $role_links = array();
                $role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
@@ -100,7 +102,11 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                return $role_links;
        }
 
-       function pagination( $which ) {
+       /**
+        * @global string $mode
+        * @param string $which
+        */
+       protected function pagination( $which ) {
                global $mode;
 
                parent::pagination ( $which );
@@ -109,7 +115,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                        $this->view_switcher( $mode );
        }
 
-       function get_columns() {
+       public function get_columns() {
                $users_columns = array(
                        'cb'         => '<input type="checkbox" />',
                        'username'   => __( 'Username' ),
@@ -118,12 +124,20 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                        'registered' => _x( 'Registered', 'user' ),
                        'blogs'      => __( 'Sites' )
                );
+               /**
+                * Filter the columns displayed in the Network Admin Users list table.
+                *
+                * @since MU
+                *
+                * @param array $users_columns An array of user columns. Default 'cb', 'username',
+                *                             'name', 'email', 'registered', 'blogs'.
+                */
                $users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
 
                return $users_columns;
        }
 
-       function get_sortable_columns() {
+       protected function get_sortable_columns() {
                return array(
                        'username'   => 'login',
                        'name'       => 'name',
@@ -132,23 +146,22 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                );
        }
 
-       function display_rows() {
-               global $current_site, $mode;
+       public function display_rows() {
+               global $mode;
 
-               $alt = '';
                $super_admins = get_super_admins();
                foreach ( $this->items as $user ) {
-                       $alt = ( 'alternate' == $alt ) ? '' : 'alternate';
+                       $class = '';
 
                        $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
 
                        foreach ( $status_list as $status => $col ) {
                                if ( $user->$status )
-                                       $alt .= " $col";
+                                       $class .= " $col";
                        }
 
                        ?>
-                       <tr class="<?php echo $alt; ?>">
+                       <tr class="<?php echo trim( $class ); ?>">
                        <?php
 
                        list( $columns, $hidden ) = $this->get_column_info();
@@ -173,10 +186,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                        case 'username':
                                                $avatar = get_avatar( $user->user_email, 32 );
-                                               $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
+                                               $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
 
                                                echo "<td $attributes>"; ?>
-                                                       <?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo stripslashes( $user->user_login ); ?></a><?php
+                                                       <?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
                                                        if ( in_array( $user->user_login, $super_admins ) )
                                                                echo ' - ' . __( 'Super Admin' );
                                                        ?></strong>
@@ -186,9 +199,19 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                                                                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
 
                                                                if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
-                                                                       $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
+                                                                       $actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
                                                                }
 
+                                                               /**
+                                                                * Filter the action links displayed under each user
+                                                                * in the Network Admin Users list table.
+                                                                *
+                                                                * @since 3.2.0
+                                                                *
+                                                                * @param array   $actions An array of action links to be displayed.
+                                                                *                         Default 'Edit', 'Delete'.
+                                                                * @param WP_User $user    WP_User object.
+                                                                */
                                                                $actions = apply_filters( 'ms_user_row_actions', $actions, $user );
                                                                echo $this->row_actions( $actions );
                                                        ?>
@@ -206,9 +229,9 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                        case 'registered':
                                                if ( 'list' == $mode )
-                                                       $date = 'Y/m/d';
+                                                       $date = __( 'Y/m/d' );
                                                else
-                                                       $date = 'Y/m/d \<\b\r \/\> g:i:s a';
+                                                       $date = __( 'Y/m/d g:i:s a' );
 
                                                echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";
                                        break;
@@ -223,7 +246,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                                                        $path   = ( $val->path == '/' ) ? '' : $val->path;
                                                                        echo '<span class="site-' . $val->site_id . '" >';
-                                                                       echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
+                                                                       echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '</a>';
                                                                        echo ' <small class="row-actions">';
                                                                        $actions = array();
                                                                        $actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
@@ -240,7 +263,17 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                                                        $actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
 
-                                                                       $actions = apply_filters('ms_user_list_site_actions', $actions, $val->userblog_id);
+                                                                       /**
+                                                                        * Filter the action links displayed next the sites a user belongs to
+                                                                        * in the Network Admin Users list table.
+                                                                        *
+                                                                        * @since 3.1.0
+                                                                        *
+                                                                        * @param array $actions     An array of action links to be displayed.
+                                                                        *                           Default 'Edit', 'View'.
+                                                                        * @param int   $userblog_id The site ID.
+                                                                        */
+                                                                       $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
 
                                                                        $i=0;
                                                                        $action_count = count( $actions );
@@ -259,6 +292,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                        default:
                                                echo "<td $attributes>";
+                                               /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
                                                echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
                                                echo "</td>";
                                        break;