WordPress.org

Make WordPress Core

Ticket #17924: wp-3.3.2-multi-role-diff.patch

File wp-3.3.2-multi-role-diff.patch, 3.7 KB (added by mobius5150, 6 years ago)

A single patch file for WP 3.3.2

  • class-wp-users-list-table.php

    # This patch file was generated by NetBeans IDE
    # Following Index: paths are relative to: I:\Work\Projects\wordpress src\3.3.2\wp-admin\includes
    # This patch can be applied using context Tools: Patch action on respective folder.
    # It uses platform neutral UTF-8 encoding and \n newlines.
    # Above lines and this line are ignored by the patching process.
     
    7373                        'total_items' => $wp_user_search->get_total(),
    7474                        'per_page' => $users_per_page,
    7575                ) );
     76               
     77                add_filter( 'user_role_name', array( &$this, 'wp_user_role_name' ), 1, 2 );
    7678        }
    7779
    7880        function no_items() {
     
    141143?>
    142144        <div class="alignleft actions">
    143145                <label class="screen-reader-text" for="new_role"><?php _e( 'Change role to&hellip;' ) ?></label>
    144                 <select name="new_role" id="new_role">
    145                         <option value=''><?php _e( 'Change role to&hellip;' ) ?></option>
    146                         <?php wp_dropdown_roles(); ?>
    147                 </select>
     146                <?php
     147                // print the full list of roles with the primary one selected.
     148                wp_user_role_selector(array(
     149                    'no_role' => false,
     150                    'id' => 'new_role',
     151                    'name' => 'new_role',
     152                    'before_list' => "<option value=''>" . _e( 'Change role to&hellip;' ) . "</option>",
     153                ));
     154                ?>
    148155                <?php submit_button( __( 'Change' ), 'secondary', 'changeit', false ); ?>
    149156        </div>
    150157<?php
     
    193200
    194201                $style = '';
    195202                foreach ( $this->items as $userid => $user_object ) {
    196                         $role = reset( $user_object->roles );
    197 
    198203                        if ( is_multisite() && empty( $role ) )
    199204                                continue;
    200205
     
    209214         * @since 2.1.0
    210215         *
    211216         * @param object $user_object
    212          * @param string $style Optional. Attributes added to the TR element. Must be sanitized.
     217         * @param string $style Optional. Attributes added to the TR element.  Must be sanitized.
    213218         * @param string $role Key for the $wp_roles array.
    214          * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts.
     219         * @param int $numposts Optional. Post count to display for this user.  Defaults to zero, as in, a new user has made zero posts.
    215220         * @return string
    216221         */
    217222        function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
     
    261266                } else {
    262267                        $edit = '<strong>' . $user_object->user_login . '</strong>';
    263268                }
    264                 $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
     269               
     270                if ( !isset( $role ) || $role == '' )
     271                    $role = $user_object->roles;
     272                if ( !is_array($role) )
     273                    $role = array( $role );
     274                $role_name = apply_filters( 'user_role_name' , $role, $role );
     275               
    265276                $avatar = get_avatar( $user_object->ID, 32 );
    266277
    267278                $r = "<tr id='user-$user_object->ID'$style>";
     
    315326
    316327                return $r;
    317328        }
     329       
     330        /**
     331         * Formats the role name for the WP_Users_List table role column.
     332         *
     333         * @param type string $role the string that is being filtered.
     334         * @param type array $roles the array of roles
     335         * @return type string
     336         */
     337        static function wp_user_role_name( $role, $roles ) {
     338            global $wp_roles;
     339            return isset( $wp_roles->role_names[$roles[0]] ) ? translate_user_role( $wp_roles->role_names[$roles[0]] ) : __( 'None' );
    318340}
     341       
     342}
     343 No newline at end of file