Ticket #47522: 47522.2.patch
File 47522.2.patch, 4.4 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/user.php
88 88 $user->user_url = preg_match( '/^(' . $protocols . '):/is', $user->user_url ) ? $user->user_url : 'http://' . $user->user_url; 89 89 } 90 90 } 91 if ( isset( $_POST['first_name'] ) ) { 92 $user->first_name = sanitize_text_field( $_POST['first_name'] ); 91 foreach ( wp_get_user_name_parts() as $key => $label ) { 92 if ( isset( $_POST[ $key ] ) ) { 93 $user->{$key} = sanitize_text_field( $_POST[ $key ] ); 94 } 93 95 } 94 if ( isset( $_POST['last_name'] ) ) {95 $user->last_name = sanitize_text_field( $_POST['last_name'] );96 }97 96 if ( isset( $_POST['nickname'] ) ) { 98 97 $user->nickname = sanitize_text_field( $_POST['nickname'] ); 99 98 } -
src/wp-admin/user-edit.php
425 425 </td></tr> 426 426 <?php } ?> 427 427 428 <tr class="user-first-name-wrap"> 429 <th><label for="first_name"><?php _e( 'First Name' ); ?></label></th> 430 <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name ); ?>" class="regular-text" /></td> 428 <?php foreach ( wp_get_user_name_parts() as $key => $label ) : ?> 429 <tr class="user-<?php echo esc_attr( str_replace( '_', '-', $key ) ) ?>-wrap"> 430 <th><label for="<?php echo esc_attr( $key ) ?>"><?php echo esc_html( $label ); ?></label></th> 431 <td><input type="text" name="<?php echo esc_attr( $key ) ?>" id="<?php echo esc_attr( $key ) ?>" value="<?php echo esc_attr( $profileuser->{$key}); ?>" class="regular-text" /></td> 431 432 </tr> 433 <?php endforeach; ?> 432 434 433 <tr class="user-last-name-wrap">434 <th><label for="last_name"><?php _e( 'Last Name' ); ?></label></th>435 <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name ); ?>" class="regular-text" /></td>436 </tr>437 438 435 <tr class="user-nickname-wrap"> 439 436 <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 440 437 <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td> -
src/wp-includes/user.php
2135 2135 } 2136 2136 2137 2137 /** 2138 * Get user name parts. 2139 * 2140 * Default name parts are first_name and last_name. 2141 * 2142 * @since 5.3.0 2143 * 2144 * @return array An associative array consists of user_meta key as key and label as value. 2145 */ 2146 function wp_get_user_name_parts() { 2147 $default = [ 2148 'first_name' => __( 'First Name' ), 2149 'middle_name' => __( 'Middle Name' ), 2150 'last_name' => __( 'Last Name' ), 2151 ]; 2152 $user_locale = get_user_locale(); 2153 /** 2154 * Filters user name parts. 2155 * 2156 * @since 5.3.0 2157 * 2158 * @param array $name_parts An associative array consists of user_meta key as key and label as value. 2159 * @param string $user_locale User locale 2160 */ 2161 $name_parts = (array) apply_filters( 'user_name_parts', $default, $user_locale ); 2162 /* 2163 * translators: Control name order in your locale. If last name precedes first name, 'last_name,first_name'. 2164 * A middle name is required, 'first_name,middle_name,last_name'. 2165 * Other name parts can be added by user_name_parts filters. 2166 */ 2167 $name_order = _x( 'first_name,last_name', 'Name order. Do not translate!' ); 2168 /** 2169 * Order of user name parts. Must be included in name parts. 2170 * 2171 * @since 5.3.0 2172 * 2173 * @param array $name_order An array of user_meta key. 2174 * @param string $user_locale User locale. 2175 */ 2176 $name_order = (array) apply_filters( 'user_name_parts_order', array_map( 'trim', explode( ',', $name_order ) ), $user_locale ); 2177 $name_order = array_filter( $name_order, function( $key ) use ( $name_parts ) { 2178 return isset( $name_parts[ $key ] ); 2179 } ); 2180 $allowed_parts = []; 2181 foreach ( $name_order as $key ) { 2182 $allowed_parts[ $key ] = $name_parts[ $key ]; 2183 } 2184 return empty( $allowed_parts ) ? [ 2185 'first_name' => __( 'First Name' ), 2186 'last_name' => __( 'Last Name' ), 2187 ] : $allowed_parts; 2188 } 2189 2190 /** 2138 2191 * Set up the user contact methods. 2139 2192 * 2140 2193 * Default contact methods were removed in 3.6. A filter dictates contact methods.