Make WordPress Core

Ticket #41931: 41931.patch

File 41931.patch, 2.6 KB (added by JPry, 8 years ago)

First pass at adding filter and cleanup

  • src/wp-admin/user-edit.php

    diff --git src/wp-admin/user-edit.php src/wp-admin/user-edit.php
    index c3c120ff37..5c553c7b2f 100644
    if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_c 
    421421        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    422422        <td>
    423423                <select name="display_name" id="display_name">
    424                 <?php
    425                         $public_display = array();
    426                         $public_display['display_nickname']  = $profileuser->nickname;
    427                         $public_display['display_username']  = $profileuser->user_login;
     424                        <?php
     425                        $public_display                     = array();
     426                        $public_display['display_nickname'] = $profileuser->nickname;
     427                        $public_display['display_username'] = $profileuser->user_login;
    428428
    429                         if ( !empty($profileuser->first_name) )
     429                        if ( ! empty( $profileuser->first_name ) ) {
    430430                                $public_display['display_firstname'] = $profileuser->first_name;
     431                        }
    431432
    432                         if ( !empty($profileuser->last_name) )
     433                        if ( ! empty( $profileuser->last_name ) ) {
    433434                                $public_display['display_lastname'] = $profileuser->last_name;
     435                        }
    434436
    435                         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
     437                        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
    436438                                $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
    437439                                $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
    438440                        }
    439441
    440                         if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
     442                        // Only add this if it isn't duplicated elsewhere
     443                        if ( ! in_array( $profileuser->display_name, $public_display ) ) {
    441444                                $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
     445                        }
     446
     447                        /**
     448                         * Filter the public display selection options.
     449                         *
     450                         * @param array   $public_display The array of public_display options.
     451                         * @param WP_User $profileuser    The user whose profile is being edited.
     452                         */
     453                        $public_display = apply_filters( 'user_profile_public_display', $public_display, $profileuser );
    442454
    443455                        $public_display = array_map( 'trim', $public_display );
    444456                        $public_display = array_unique( $public_display );
    445457
    446458                        foreach ( $public_display as $id => $item ) {
    447                 ?>
    448                         <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
    449                 <?php
     459                                ?>
     460                                <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
     461                                <?php
    450462                        }
    451                 ?>
     463                        ?>
    452464                </select>
    453465        </td>
    454466</tr>