wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_dropdown_roles › WordPress Function

Da2.1.0
Deprecaton/a
› wp_dropdown_roles ( $selected = '', $editable_roles = null )
Parametri: (2)
  • (string) $selected Slug for the role that should be already selected.
    Richiesto: No
    Default: (vuoto)
  • (array) $editable_roles Array of roles to include in the dropdown. Defaults to all roles the current user is allowed to edit.
    Richiesto: No
    Default: null
Definito a:
Codex:
ChangeLog:
  • 7.0.0

Prints out option HTML elements for role selectors.



Sorgenti

function wp_dropdown_roles( $selected = '', $editable_roles = null ) {
	$r = '';

	if ( null === $editable_roles ) {
		$editable_roles = array_reverse( get_editable_roles() );
	}

	foreach ( $editable_roles as $role => $details ) {
		$name = translate_user_role( $details['name'] );
		// Preselect specified role.
		if ( $selected === $role ) {
			$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
		} else {
			$r .= "\n\t<option value='" . esc_attr( $role ) . "'>$name</option>";
		}
	}

	echo $r;
}