WordPress.org

Make WordPress Core

Ticket #8761: alter_wp_dropdown_roles.diff

File alter_wp_dropdown_roles.diff, 1.2 KB (added by jeremyclarke, 9 years ago)

add filter to wp_dropdown_roles()

  • wp-admin/includes/template.php

     
    25862586<?php
    25872587}
    25882588
     2589 
    25892590/**
    2590  * {@internal Missing Short Description}}
     2591 * Print out <option> html elements for role selectors based on $wp_roles
    25912592 *
    2592  * @since unknown
     2593 * @package WordPress
     2594 * @subpackage Administration
     2595 * @since 2.1
    25932596 *
    2594  * @param unknown_type $default
     2597 * @uses $wp_roles
     2598 * @param string $default slug for the role that should be already selected
    25952599 */
    2596 function wp_dropdown_roles( $default = false ) {
     2600function wp_dropdown_roles( $selected = false ) {
    25972601        global $wp_roles;
    25982602        $p = '';
    25992603        $r = '';
    2600         foreach( $wp_roles->role_names as $role => $name ) {
     2604       
     2605        $role_names = $wp_roles->role_names;
     2606        $role_names = apply_filters('role_names_listing', $role_names);
     2607       
     2608        foreach( $role_names as $role => $name ) {
    26012609                $name = translate_with_context($name);
    2602                 if ( $default == $role ) // Make default first in list
     2610                if ( $selected == $role ) // Make default first in list
    26032611                        $p = "\n\t<option selected='selected' value='$role'>$name</option>";
    26042612                else
    26052613                        $r .= "\n\t<option value='$role'>$name</option>";