]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-ms-users-list-table.php
WordPress 3.9.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-ms-users-list-table.php
index 36d55e1ca16daf65a6d2719384d2d58e8e467c64..df0640686bf2192cb795f3ca76dce00e1531f2be 100644 (file)
@@ -16,7 +16,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
        function prepare_items() {
                global $usersearch, $role, $wpdb, $mode;
 
        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' );
 
 
                $users_per_page = $this->get_items_per_page( 'users_network_per_page' );
 
@@ -32,7 +32,8 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                        'fields' => 'all_with_meta'
                );
 
                        'fields' => 'all_with_meta'
                );
 
-               $args['search'] = ltrim($args['search'], '*');
+               if ( wp_is_large_network( 'users' ) )
+                       $args['search'] = ltrim( $args['search'], '*' );
 
                if ( $role == 'super' ) {
                        $logins = implode( "', '", get_super_admins() );
 
                if ( $role == 'super' ) {
                        $logins = implode( "', '", get_super_admins() );
@@ -41,7 +42,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                // 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 && ( get_blog_count() >= 10000 ) ) {
+               if ( !$usersearch && wp_is_large_network( 'users' ) ) {
                        if ( !isset($_REQUEST['orderby']) )
                                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
                        if ( !isset($_REQUEST['order']) )
                        if ( !isset($_REQUEST['orderby']) )
                                $_GET['orderby'] = $_REQUEST['orderby'] = 'id';
                        if ( !isset($_REQUEST['order']) )
@@ -117,6 +118,14 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                        'registered' => _x( 'Registered', 'user' ),
                        'blogs'      => __( 'Sites' )
                );
                        '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;
                $users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
 
                return $users_columns;
@@ -132,7 +141,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
        }
 
        function display_rows() {
        }
 
        function display_rows() {
-               global $current_site, $mode;
+               global $mode;
 
                $alt = '';
                $super_admins = get_super_admins();
 
                $alt = '';
                $super_admins = get_super_admins();
@@ -161,10 +170,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                $attributes = "$class$style";
 
 
                                $attributes = "$class$style";
 
-
                                switch ( $column_name ) {
                                        case 'cb': ?>
                                                <th scope="row" class="check-column">
                                switch ( $column_name ) {
                                        case 'cb': ?>
                                                <th scope="row" class="check-column">
+                                                       <label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
                                                        <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
                                                </th>
                                        <?php
                                                        <input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
                                                </th>
                                        <?php
@@ -172,14 +181,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                        case 'username':
                                                $avatar = get_avatar( $user->user_email, 32 );
 
                                        case 'username':
                                                $avatar = get_avatar( $user->user_email, 32 );
-                                               if ( get_current_user_id() == $user->ID ) {
-                                                       $edit_link = esc_url( network_admin_url( 'profile.php' ) );
-                                               } else {
-                                                       $edit_link = esc_url( network_admin_url( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), 'user-edit.php?user_id=' . $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>"; ?>
 
                                                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>
                                                        if ( in_array( $user->user_login, $super_admins ) )
                                                                echo ' - ' . __( 'Super Admin' );
                                                        ?></strong>
@@ -188,10 +193,21 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                                                                $actions = array();
                                                                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
 
                                                                $actions = array();
                                                                $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( 'edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</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( 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 );
                                                        ?>
                                                </td>
                                                                echo $this->row_actions( $actions );
                                                        ?>
                                                </td>
@@ -225,7 +241,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                                                        $path   = ( $val->path == '/' ) ? '' : $val->path;
                                                                        echo '<span class="site-' . $val->site_id . '" >';
 
                                                                        $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>';
                                                                        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,9 +256,19 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                                                                        if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 )
                                                                                $class .= 'site-archived ';
 
                                                                        if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 )
                                                                                $class .= 'site-archived ';
 
-                                                                       $actions['view'] = '<a class="' . $class . '" href="' .  esc_url( get_home_url( $val->userblog_id ) )  . '">' . __( 'View' ) . '</a>';
+                                                                       $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 );
 
                                                                        $i=0;
                                                                        $action_count = count( $actions );
@@ -261,6 +287,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
 
                                        default:
                                                echo "<td $attributes>";
 
                                        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;
                                                echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
                                                echo "</td>";
                                        break;
@@ -272,5 +299,3 @@ class WP_MS_Users_List_Table extends WP_List_Table {
                }
        }
 }
                }
        }
 }
-
-?>