WordPress.org

Make WordPress Core

Ticket #15342: site.users.add.15342.patch

File site.users.add.15342.patch, 3.6 KB (added by ocean90, 8 years ago)
  • wp-admin/network/site-users.php

     
    2525if ( $details->site_id != $wpdb->siteid )
    2626        wp_die( __( 'You do not have permission to access this page.' ) );
    2727
     28// get blog prefix
     29$blog_prefix = $wpdb->get_blog_prefix( $id );
     30
     31// @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog.
     32if ( ! empty($wp_roles->use_db) ) {
     33        // If using the DB to store roles, consult the user_roles option.
     34        $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
     35} else {
     36        // Roles are stored in memory, not the DB.
     37        $editblog_roles = $wp_roles->roles;
     38}
     39
    2840$is_main_site = is_main_site( $id );
    2941
    3042if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) {
     
    3244
    3345        switch_to_blog( $id );
    3446
    35         // get blog prefix
    36         $blog_prefix = $wpdb->get_blog_prefix( $id );
    37 
    3847        // user roles
    3948        if ( isset( $_POST['role'] ) && is_array( $_POST['role'] ) == true ) {
    4049                $newroles = $_POST['role'];
     
    131140<?php
    132141$blogusers = get_users( array( 'blog_id' => $id, 'number' => 20 ) );
    133142if ( is_array( $blogusers ) ) {
    134         echo '<table class="form-table">';
    135         echo "<tr><th>" . __( 'User' ) . "</th><th>" . __( 'Role' ) . "</th><th>" . __( 'Password' ) . "</th><th>" . __( 'Remove' ) . "</th></tr>";
     143        echo '<table class="widefat fixed">';
     144        $columns = "<tr><th scope='col' class='manage-column'>" . __( 'User' ) . "</th><th scope='col' class='manage-column'>" . __( 'Role' ) . "</th><th scope='col' class='manage-column'>" . __( 'Password' ) . "</th><th scope='col' class='manage-column'>" . __( 'Remove' ) . "</th></tr>";
     145        echo "<thead>" . $columns . "</thead><tfoot>" . $columns . "</tfoot><tbody class='form-table'>";
    136146        $user_count = 0;
    137         // @todo This is a hack. Eventually, add API to WP_Roles allowing retrieval of roles for a particular blog.
    138         if ( ! empty($wp_roles->use_db) ) {
    139                 // If using the DB to store roles, consult the user_roles option.
    140                 $blog_prefix = $wpdb->get_blog_prefix( $id );
    141                 $editblog_roles = get_blog_option( $id, "{$blog_prefix}user_roles" );
    142         } else {
    143                 // Roles are stored in memory, not the DB.
    144                 $editblog_roles = $wp_roles->roles;
    145         }
    146147
    147148        foreach ( $blogusers as $user_id => $user_object ) {
    148149                $user_count++;
     
    170171                }
    171172                echo '</tr>';
    172173        }
    173         echo "</table>";
    174         submit_button();
     174        echo "</tbody></table>";
     175
    175176        if ( 20 == $user_count )
    176177                echo '<p>' . sprintf( __('First 20 users shown. <a href="%s">Manage all users</a>.'), get_admin_url($id, 'users.php') ) . '</p>';
    177178} else {
    178179        _e('This site has no users.');
    179180}
    180181?>
     182<br class="clear" />
     183<h3><?php _e( 'Add a new user' ); ?></h3>
     184<p class="description"><?php _e( 'Enter the username of an existing user and hit &#8220;Save Changes&#8221; to add the user.' ) ?></p>
     185<table class="form-table">
     186        <tr valign="top">
     187                <th scope="row"><?php _e( 'User&nbsp;Login:' ) ?></th>
     188                <td><input type="text" name="newuser" id="newuser" /></td>
     189        </tr>
     190        <tr valign="top">
     191                <th scope="row"><?php _e( 'Role:' ) ?></th>
     192                <td>
     193                        <select name="new_role" id="new_role_0">
     194                        <?php
     195                        reset( $editblog_roles );
     196                        foreach ( $editblog_roles as $role => $role_assoc ) {
     197                                $name = translate_user_role( $role_assoc['name'] );
     198                                $selected = ( $role == $editblog_default_role ) ? 'selected="selected"' : '';
     199                                echo '<option ' . $selected . ' value="' . esc_attr( $role ) . '">' . esc_html( $name ) . '</option>';
     200                        } ?>
     201                        </select>
     202                </td>
     203        </tr>
     204</table>
     205<?php submit_button(); ?>
    181206</form>
    182207
    183208</div>