diff -r e185f8cbbec5 wp-admin/includes/template.php
|
a
|
b
|
|
| 751 | 751 | /** |
| 752 | 752 | * Print out <option> html elements for role selectors |
| 753 | 753 | * |
| | 754 | * <code> |
| | 755 | * // call with a single pre-selected option |
| | 756 | * wp_dropdown_roles( 'editor' ): |
| | 757 | * |
| | 758 | * // call with multiple pre-selected options |
| | 759 | * wp_dropdown_roles( array( 'editor', 'administrator' ) ): |
| | 760 | * </code> |
| | 761 | * |
| 754 | 762 | * @since 2.1.0 |
| 755 | 763 | * |
| 756 | | * @param string $selected slug for the role that should be already selected |
| | 764 | * @param string|array $selected list of role slugs that should be already |
| | 765 | * selected |
| | 766 | * @return string list of HTML <option> elements with user roles |
| 757 | 767 | */ |
| 758 | 768 | function wp_dropdown_roles( $selected = false ) { |
| 759 | 769 | $p = ''; |
| … |
… |
|
| 761 | 771 | |
| 762 | 772 | $editable_roles = get_editable_roles(); |
| 763 | 773 | |
| | 774 | // For backwards compatibility |
| | 775 | if ( is_string($selected) ) |
| | 776 | $selected = array( $selected ); |
| | 777 | |
| 764 | 778 | foreach ( $editable_roles as $role => $details ) { |
| 765 | 779 | $name = translate_user_role($details['name'] ); |
| 766 | | if ( $selected == $role ) // preselect specified role |
| 767 | | $p = "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
| | 780 | if ( is_array($selected) AND in_array($role,$selected) ) // preselect specified role |
| | 781 | $p .= "\n\t<option selected='selected' value='" . esc_attr($role) . "'>$name</option>"; |
| 768 | 782 | else |
| 769 | 783 | $r .= "\n\t<option value='" . esc_attr($role) . "'>$name</option>"; |
| 770 | 784 | } |