Make WordPress Core

Ticket #49924: 49924.diff

File 49924.diff, 1.1 KB (added by abdulawal39, 4 years ago)

Updated function code

  • src/wp-admin/includes/template.php

     
    922922 *
    923923 * @since 2.1.0
    924924 *
    925  * @param string $selected Slug for the role that should be already selected.
     925 * @param string|array $selected Slug for the role that should be already selected.
    926926 */
    927927function wp_dropdown_roles( $selected = '' ) {
    928928        $r = '';
    929929
     930        if( ! is_array( $selected ) ){
     931                $parsed_selected = explode( ",", $selected );
     932        } else {
     933                $parsed_selected = wp_parse_args( $selected );
     934        }
     935
    930936        $editable_roles = array_reverse( get_editable_roles() );
    931937
    932938        foreach ( $editable_roles as $role => $details ) {
    933939                $name = translate_user_role( $details['name'] );
    934940                // Preselect specified role.
    935                 if ( $selected == $role ) {
     941                if ( in_array( $role, $parsed_selected ) ) {
    936942                        $r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
    937943                } else {
    938944                        $r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";