Changeset 42343 for trunk/src/wp-admin/user-edit.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/user-edit.php (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/user-edit.php
r42217 r42343 12 12 wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) ); 13 13 14 $user_id = (int) $user_id;14 $user_id = (int) $user_id; 15 15 $current_user = wp_get_current_user(); 16 if ( ! defined( 'IS_PROFILE_PAGE' ) ) 16 if ( ! defined( 'IS_PROFILE_PAGE' ) ) { 17 17 define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); 18 19 if ( ! $user_id && IS_PROFILE_PAGE ) 18 } 19 20 if ( ! $user_id && IS_PROFILE_PAGE ) { 20 21 $user_id = $current_user->ID; 21 elseif ( ! $user_id && ! IS_PROFILE_PAGE ) 22 wp_die(__( 'Invalid user ID.' ) ); 23 elseif ( ! get_userdata( $user_id ) ) 24 wp_die( __('Invalid user ID.') ); 25 26 wp_enqueue_script('user-profile'); 22 } elseif ( ! $user_id && ! IS_PROFILE_PAGE ) { 23 wp_die( __( 'Invalid user ID.' ) ); 24 } elseif ( ! get_userdata( $user_id ) ) { 25 wp_die( __( 'Invalid user ID.' ) ); 26 } 27 28 wp_enqueue_script( 'user-profile' ); 27 29 28 30 if ( IS_PROFILE_PAGE ) { … … 33 35 } 34 36 35 if ( current_user_can( 'edit_users') && !IS_PROFILE_PAGE )37 if ( current_user_can( 'edit_users' ) && ! IS_PROFILE_PAGE ) { 36 38 $submenu_file = 'users.php'; 37 else 39 } else { 38 40 $submenu_file = 'profile.php'; 39 40 if ( current_user_can('edit_users') && !is_user_admin() ) 41 } 42 43 if ( current_user_can( 'edit_users' ) && ! is_user_admin() ) { 41 44 $parent_file = 'users.php'; 42 else 45 } else { 43 46 $parent_file = 'profile.php'; 44 45 $profile_help = '<p>' . __('Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.') . '</p>' . 46 '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' . 47 } 48 49 $profile_help = '<p>' . __( 'Your profile contains information about you (your “account”) as well as some personal options related to using WordPress.' ) . '</p>' . 50 '<p>' . __( 'You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.' ) . '</p>' . 47 51 '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' . 48 '<p>' . __( 'Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' .52 '<p>' . __( 'Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.' ) . '</p>' . 49 53 '<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out Everywhere Else button.' ) . '</p>' . 50 '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' . 51 '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>'; 52 53 get_current_screen()->add_help_tab( array( 54 'id' => 'overview', 55 'title' => __('Overview'), 56 'content' => $profile_help, 57 ) ); 54 '<p>' . __( 'Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.' ) . '</p>' . 55 '<p>' . __( 'Remember to click the Update Profile button when you are finished.' ) . '</p>'; 56 57 get_current_screen()->add_help_tab( 58 array( 59 'id' => 'overview', 60 'title' => __( 'Overview' ), 61 'content' => $profile_help, 62 ) 63 ); 58 64 59 65 get_current_screen()->set_help_sidebar( 60 '<p><strong>' . __('For more information:') . '</strong></p>' .61 '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' .62 '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'66 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 67 '<p>' . __( '<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>' ) . '</p>' . 68 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' 63 69 ); 64 70 … … 89 95 90 96 // Execute confirmed email change. See send_confirmation_on_profile_email(). 91 if ( IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail'] ) && $current_user->ID ) {97 if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) { 92 98 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 93 if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail'] ) ) {94 $user = new stdClass;95 $user->ID = $current_user->ID;96 $user->user_email = esc_html( trim( $new_email[ 'newemail'] ) );99 if ( $new_email && hash_equals( $new_email['hash'], $_GET['newuseremail'] ) ) { 100 $user = new stdClass; 101 $user->ID = $current_user->ID; 102 $user->user_email = esc_html( trim( $new_email['newemail'] ) ); 97 103 if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) { 98 104 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) ); … … 108 114 check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' ); 109 115 delete_user_meta( $current_user->ID, '_new_email' ); 110 wp_redirect( add_query_arg( array( 'updated' => 'true'), self_admin_url( 'profile.php' ) ) );116 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) ); 111 117 die(); 112 118 } 113 119 114 switch ($action) { 115 case 'update': 116 117 check_admin_referer('update-user_' . $user_id); 118 119 if ( !current_user_can('edit_user', $user_id) ) 120 wp_die(__('Sorry, you are not allowed to edit this user.')); 121 122 if ( IS_PROFILE_PAGE ) { 123 /** 124 * Fires before the page loads on the 'Your Profile' editing screen. 125 * 126 * The action only fires if the current user is editing their own profile. 127 * 128 * @since 2.0.0 129 * 130 * @param int $user_id The user ID. 131 */ 132 do_action( 'personal_options_update', $user_id ); 133 } else { 134 /** 135 * Fires before the page loads on the 'Edit User' screen. 136 * 137 * @since 2.7.0 138 * 139 * @param int $user_id The user ID. 140 */ 141 do_action( 'edit_user_profile_update', $user_id ); 142 } 143 144 // Update the email address in signups, if present. 145 if ( is_multisite() ) { 146 $user = get_userdata( $user_id ); 147 148 if ( $user->user_login && isset( $_POST[ 'email' ] ) && is_email( $_POST[ 'email' ] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { 149 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) ); 150 } 151 } 152 153 // Update the user. 154 $errors = edit_user( $user_id ); 155 156 // Grant or revoke super admin status if requested. 157 if ( is_multisite() && is_network_admin() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) { 158 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 159 } 160 161 if ( !is_wp_error( $errors ) ) { 162 $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); 163 if ( $wp_http_referer ) 164 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect); 165 wp_redirect($redirect); 166 exit; 167 } 168 169 default: 170 $profileuser = get_user_to_edit($user_id); 171 172 if ( !current_user_can('edit_user', $user_id) ) 173 wp_die(__('Sorry, you are not allowed to edit this user.')); 174 175 $title = sprintf( $title, $profileuser->display_name ); 176 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); 177 178 include(ABSPATH . 'wp-admin/admin-header.php'); 179 ?> 180 181 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?> 182 <div class="notice notice-info"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div> 120 switch ( $action ) { 121 case 'update': 122 check_admin_referer( 'update-user_' . $user_id ); 123 124 if ( ! current_user_can( 'edit_user', $user_id ) ) { 125 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 126 } 127 128 if ( IS_PROFILE_PAGE ) { 129 /** 130 * Fires before the page loads on the 'Your Profile' editing screen. 131 * 132 * The action only fires if the current user is editing their own profile. 133 * 134 * @since 2.0.0 135 * 136 * @param int $user_id The user ID. 137 */ 138 do_action( 'personal_options_update', $user_id ); 139 } else { 140 /** 141 * Fires before the page loads on the 'Edit User' screen. 142 * 143 * @since 2.7.0 144 * 145 * @param int $user_id The user ID. 146 */ 147 do_action( 'edit_user_profile_update', $user_id ); 148 } 149 150 // Update the email address in signups, if present. 151 if ( is_multisite() ) { 152 $user = get_userdata( $user_id ); 153 154 if ( $user->user_login && isset( $_POST['email'] ) && is_email( $_POST['email'] ) && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $user->user_login ) ) ) { 155 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST['email'], $user_login ) ); 156 } 157 } 158 159 // Update the user. 160 $errors = edit_user( $user_id ); 161 162 // Grant or revoke super admin status if requested. 163 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) ) { 164 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 165 } 166 167 if ( ! is_wp_error( $errors ) ) { 168 $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) ); 169 if ( $wp_http_referer ) { 170 $redirect = add_query_arg( 'wp_http_referer', urlencode( $wp_http_referer ), $redirect ); 171 } 172 wp_redirect( $redirect ); 173 exit; 174 } 175 176 default: 177 $profileuser = get_user_to_edit( $user_id ); 178 179 if ( ! current_user_can( 'edit_user', $user_id ) ) { 180 wp_die( __( 'Sorry, you are not allowed to edit this user.' ) ); 181 } 182 183 $title = sprintf( $title, $profileuser->display_name ); 184 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID ); 185 186 include( ABSPATH . 'wp-admin/admin-header.php' ); 187 ?> 188 189 <?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?> 190 <div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div> 183 191 <?php } ?> 184 <?php if ( isset( $_GET['updated']) ) : ?>192 <?php if ( isset( $_GET['updated'] ) ) : ?> 185 193 <div id="message" class="updated notice is-dismissible"> 186 194 <?php if ( IS_PROFILE_PAGE ) : ?> 187 <p><strong><?php _e( 'Profile updated.')?></strong></p>188 <?php else : ?>189 <p><strong><?php _e( 'User updated.')?></strong></p>195 <p><strong><?php _e( 'Profile updated.' ); ?></strong></p> 196 <?php else : ?> 197 <p><strong><?php _e( 'User updated.' ); ?></strong></p> 190 198 <?php endif; ?> 191 199 <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?> 192 <p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '← Back to Users'); ?></a></p>200 <p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '← Back to Users' ); ?></a></p> 193 201 <?php endif; ?> 194 202 </div> … … 206 214 207 215 <div class="wrap" id="profile-page"> 208 <h1 class="wp-heading-inline"><?php 216 <h1 class="wp-heading-inline"> 217 <?php 209 218 echo esc_html( $title ); 210 ?></h1> 219 ?> 220 </h1> 211 221 212 222 <?php 213 223 if ( ! IS_PROFILE_PAGE ) { 214 if ( current_user_can( 'create_users' ) ) { ?> 224 if ( current_user_can( 'create_users' ) ) { 225 ?> 215 226 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a> 216 227 <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?> 217 228 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a> 218 <?php } 229 <?php 230 } 219 231 } 220 232 ?> … … 222 234 <hr class="wp-header-end"> 223 235 224 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate"<?php 225 /** 226 * Fires inside the your-profile form tag on the user editing screen. 227 * 228 * @since 3.0.0 229 */ 230 do_action( 'user_edit_form_tag' ); 231 ?>> 232 <?php wp_nonce_field('update-user_' . $user_id) ?> 236 <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate" 237 <?php 238 /** 239 * Fires inside the your-profile form tag on the user editing screen. 240 * 241 * @since 3.0.0 242 */ 243 do_action( 'user_edit_form_tag' ); 244 ?> 245 > 246 <?php wp_nonce_field( 'update-user_' . $user_id ); ?> 233 247 <?php if ( $wp_http_referer ) : ?> 234 <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer); ?>" />248 <input type="hidden" name="wp_http_referer" value="<?php echo esc_url( $wp_http_referer ); ?>" /> 235 249 <?php endif; ?> 236 250 <p> … … 258 272 // Edit themes. 259 273 user_can( $profileuser, 'edit_themes' ) 260 );261 ?>262 <?php if ( $show_syntax_highlighting_preference ) : ?>274 ); 275 ?> 276 <?php if ( $show_syntax_highlighting_preference ) : ?> 263 277 <tr class="user-syntax-highlighting-wrap"> 264 278 <th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th> … … 268 282 </tr> 269 283 <?php endif; ?> 270 <?php if ( count( $_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>284 <?php if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) : ?> 271 285 <tr class="user-admin-color-wrap"> 272 <th scope="row"><?php _e('Admin Color Scheme')?></th> 273 <td><?php 286 <th scope="row"><?php _e( 'Admin Color Scheme' ); ?></th> 287 <td> 288 <?php 274 289 /** 275 290 * Fires in the 'Admin Color Scheme' section of the user editing screen. … … 284 299 */ 285 300 do_action( 'admin_color_scheme_picker', $user_id ); 286 ?></td> 301 ?> 302 </td> 287 303 </tr> 288 304 <?php 289 305 endif; // $_wp_admin_css_colors 290 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 306 if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : 307 ?> 291 308 <tr class="user-comment-shortcuts-wrap"> 292 309 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 293 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td>310 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php checked( 'true', $profileuser->comment_shortcuts ); ?> /> <?php _e( 'Enable keyboard shortcuts for comment moderation.' ); ?></label> <?php _e( '<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>' ); ?></td> 294 311 </tr> 295 312 <?php endif; ?> 296 313 <tr class="show-admin-bar user-admin-bar-front-wrap"> 297 314 <th scope="row"><?php _e( 'Toolbar' ); ?></th> 298 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Toolbar')?></span></legend>315 <td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Toolbar' ); ?></span></legend> 299 316 <label for="admin_bar_front"> 300 317 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> … … 306 323 <?php 307 324 $languages = get_available_languages(); 308 if ( $languages ) : ?> 325 if ( $languages ) : 326 ?> 309 327 <tr class="user-language-wrap"> 310 328 <th scope="row"> … … 322 340 } 323 341 324 wp_dropdown_languages( array( 325 'name' => 'locale', 326 'id' => 'locale', 327 'selected' => $user_locale, 328 'languages' => $languages, 329 'show_available_translations' => false, 330 'show_option_site_default' => true 331 ) ); 342 wp_dropdown_languages( 343 array( 344 'name' => 'locale', 345 'id' => 'locale', 346 'selected' => $user_locale, 347 'languages' => $languages, 348 'show_available_translations' => false, 349 'show_option_site_default' => true, 350 ) 351 ); 332 352 ?> 333 353 </td> … … 350 370 </table> 351 371 <?php 352 if ( IS_PROFILE_PAGE ) {353 /**354 * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.355 *356 * The action only fires if the current user is editing their own profile.357 *358 * @since 2.0.0359 *360 * @param WP_User $profileuser The current WP_User object.361 */362 do_action( 'profile_personal_options', $profileuser );363 }372 if ( IS_PROFILE_PAGE ) { 373 /** 374 * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen. 375 * 376 * The action only fires if the current user is editing their own profile. 377 * 378 * @since 2.0.0 379 * 380 * @param WP_User $profileuser The current WP_User object. 381 */ 382 do_action( 'profile_personal_options', $profileuser ); 383 } 364 384 ?> 365 385 … … 368 388 <table class="form-table"> 369 389 <tr class="user-user-login-wrap"> 370 <th><label for="user_login"><?php _e( 'Username'); ?></label></th>371 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>372 </tr> 373 374 <?php if ( ! IS_PROFILE_PAGE && !is_network_admin() ) : ?>375 <tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role')?></label></th>390 <th><label for="user_login"><?php _e( 'Username' ); ?></label></th> 391 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr( $profileuser->user_login ); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e( 'Usernames cannot be changed.' ); ?></span></td> 392 </tr> 393 394 <?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() ) : ?> 395 <tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th> 376 396 <td><select name="role" id="role"> 377 397 <?php … … 381 401 382 402 // print the full list of roles with the primary one selected. 383 wp_dropdown_roles( $user_role);403 wp_dropdown_roles( $user_role ); 384 404 385 405 // print the 'no role' option. Make it selected if the user has no role yet. 386 if ( $user_role ) 387 echo '<option value="">' . __('— No role for this site —') . '</option>'; 388 else 389 echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; 406 if ( $user_role ) { 407 echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; 408 } else { 409 echo '<option value="" selected="selected">' . __( '— No role for this site —' ) . '</option>'; 410 } 390 411 ?> 391 412 </select></td></tr> 392 <?php endif; //!IS_PROFILE_PAGE 393 394 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> 395 <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th> 413 <?php 414 endif; //!IS_PROFILE_PAGE 415 416 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) { 417 ?> 418 <tr class="user-super-admin-wrap"><th><?php _e( 'Super Admin' ); ?></th> 396 419 <td> 397 420 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> … … 404 427 405 428 <tr class="user-first-name-wrap"> 406 <th><label for="first_name"><?php _e( 'First Name')?></label></th>407 <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr( $profileuser->first_name)?>" class="regular-text" /></td>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> 408 431 </tr> 409 432 410 433 <tr class="user-last-name-wrap"> 411 <th><label for="last_name"><?php _e( 'Last Name')?></label></th>412 <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr( $profileuser->last_name)?>" class="regular-text" /></td>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> 413 436 </tr> 414 437 415 438 <tr class="user-nickname-wrap"> 416 <th><label for="nickname"><?php _e( 'Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>417 <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname)?>" class="regular-text" /></td>439 <th><label for="nickname"><?php _e( 'Nickname' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 440 <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr( $profileuser->nickname ); ?>" class="regular-text" /></td> 418 441 </tr> 419 442 420 443 <tr class="user-display-name-wrap"> 421 <th><label for="display_name"><?php _e( 'Display name publicly as')?></label></th>444 <th><label for="display_name"><?php _e( 'Display name publicly as' ); ?></label></th> 422 445 <td> 423 446 <select name="display_name" id="display_name"> 424 447 <?php 425 $public_display = array(); 426 $public_display['display_nickname'] = $profileuser->nickname; 427 $public_display['display_username'] = $profileuser->user_login; 428 429 if ( !empty($profileuser->first_name) ) 430 $public_display['display_firstname'] = $profileuser->first_name; 431 432 if ( !empty($profileuser->last_name) ) 433 $public_display['display_lastname'] = $profileuser->last_name; 434 435 if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) { 436 $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; 437 $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; 438 } 439 440 if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere 441 $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; 448 $public_display = array(); 449 $public_display['display_nickname'] = $profileuser->nickname; 450 $public_display['display_username'] = $profileuser->user_login; 451 452 if ( ! empty( $profileuser->first_name ) ) { 453 $public_display['display_firstname'] = $profileuser->first_name; 454 } 455 456 if ( ! empty( $profileuser->last_name ) ) { 457 $public_display['display_lastname'] = $profileuser->last_name; 458 } 459 460 if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) { 461 $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name; 462 $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; 463 } 464 465 if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere 466 $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; 467 } 442 468 443 469 $public_display = array_map( 'trim', $public_display ); 444 470 $public_display = array_unique( $public_display ); 445 471 446 foreach ( $public_display as $id => $item ) {472 foreach ( $public_display as $id => $item ) { 447 473 ?> 448 <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>474 <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option> 449 475 <?php 450 }476 } 451 477 ?> 452 478 </select> 453 </td> 454 </tr> 455 </table> 456 457 <h2><?php _e( 'Contact Info' ); ?></h2> 458 459 <table class="form-table"> 460 <tr class="user-email-wrap"> 461 <th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 462 <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" /> 463 <?php 464 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 465 if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?> 466 <div class="updated inline"> 467 <p><?php 479 </td> 480 </tr> 481 </table> 482 483 <h2><?php _e( 'Contact Info' ); ?></h2> 484 485 <table class="form-table"> 486 <tr class="user-email-wrap"> 487 <th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th> 488 <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ); ?>" class="regular-text ltr" /> 489 <?php 490 $new_email = get_user_meta( $current_user->ID, '_new_email', true ); 491 if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : 492 ?> 493 <div class="updated inline"> 494 <p> 495 <?php 468 496 printf( 469 497 /* translators: %s: new email */ … … 476 504 __( 'Cancel' ) 477 505 ); 478 ?></p> 479 </div> 480 <?php endif; ?> 506 ?> 507 </p> 508 </div> 509 <?php endif; ?> 481 510 </td> 482 </tr>483 484 <tr class="user-url-wrap">485 <th><label for="url"><?php _e( 'Website')?></label></th>486 <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td>487 </tr>488 489 <?php511 </tr> 512 513 <tr class="user-url-wrap"> 514 <th><label for="url"><?php _e( 'Website' ); ?></label></th> 515 <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ); ?>" class="regular-text code" /></td> 516 </tr> 517 518 <?php 490 519 foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) { 491 ?>492 <tr class="user-<?php echo $name; ?>-wrap">493 <th><label for="<?php echo $name; ?>">494 <?php495 /**496 * Filters a user contactmethod label.497 *498 * The dynamic portion of the filter hook, `$name`, refers to499 * each of the keys in the contactmethods array.500 *501 * @since 2.9.0502 *503 * @param string $desc The translatable label for the contactmethod.504 */505 echo apply_filters( "user_{$name}_label", $desc );506 ?>520 ?> 521 <tr class="user-<?php echo $name; ?>-wrap"> 522 <th><label for="<?php echo $name; ?>"> 523 <?php 524 /** 525 * Filters a user contactmethod label. 526 * 527 * The dynamic portion of the filter hook, `$name`, refers to 528 * each of the keys in the contactmethods array. 529 * 530 * @since 2.9.0 531 * 532 * @param string $desc The translatable label for the contactmethod. 533 */ 534 echo apply_filters( "user_{$name}_label", $desc ); 535 ?> 507 536 </label></th> 508 <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name)?>" class="regular-text" /></td>509 </tr>510 <?php537 <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td> 538 </tr> 539 <?php 511 540 } 512 ?>513 </table>514 515 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>541 ?> 542 </table> 543 544 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2> 516 545 517 546 <table class="form-table"> 518 547 <tr class="user-description-wrap"> 519 <th><label for="description"><?php _e( 'Biographical Info'); ?></label></th>548 <th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th> 520 549 <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea> 521 <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>550 <p class="description"><?php _e( 'Share a little biographical information to fill out your profile. This may be shown publicly.' ); ?></p></td> 522 551 </tr> 523 552 … … 527 556 <td> 528 557 <?php echo get_avatar( $user_id ); ?> 529 <p class="description"><?php 530 if ( IS_PROFILE_PAGE ) { 531 /* translators: %s: Gravatar URL */ 532 $description = sprintf( __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ), 533 __( 'https://en.gravatar.com/' ) 534 ); 535 } else { 536 $description = ''; 537 } 558 <p class="description"> 559 <?php 560 if ( IS_PROFILE_PAGE ) { 561 /* translators: %s: Gravatar URL */ 562 $description = sprintf( 563 __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ), 564 __( 'https://en.gravatar.com/' ) 565 ); 566 } else { 567 $description = ''; 568 } 538 569 539 570 /** … … 547 578 */ 548 579 echo apply_filters( 'user_profile_picture_description', $description, $profileuser ); 549 ?></p> 580 ?> 581 </p> 550 582 </td> 551 583 </tr> 552 584 <?php endif; ?> 553 585 554 <?php555 /**556 * Filters the display of the password fields.557 *558 * @since 1.5.1559 * @since 2.8.0 Added the `$profileuser` parameter.560 * @since 4.4.0 Now evaluated only in user-edit.php.561 *562 * @param bool $show Whether to show the password fields. Default true.563 * @param WP_User $profileuser User object for the current user to edit.564 */565 if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) :566 ?>567 </table>568 569 <h2><?php _e( 'Account Management' ); ?></h2>586 <?php 587 /** 588 * Filters the display of the password fields. 589 * 590 * @since 1.5.1 591 * @since 2.8.0 Added the `$profileuser` parameter. 592 * @since 4.4.0 Now evaluated only in user-edit.php. 593 * 594 * @param bool $show Whether to show the password fields. Default true. 595 * @param WP_User $profileuser User object for the current user to edit. 596 */ 597 if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) : 598 ?> 599 </table> 600 601 <h2><?php _e( 'Account Management' ); ?></h2> 570 602 <table class="form-table"> 571 603 <tr id="password" class="user-pass1-wrap"> … … 608 640 609 641 <?php 610 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?> 642 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : 643 ?> 611 644 <tr class="user-sessions-wrap hide-if-no-js"> 612 645 <th><?php _e( 'Sessions' ); ?></th> … … 643 676 <?php endif; ?> 644 677 645 </table>646 647 <?php678 </table> 679 680 <?php 648 681 if ( IS_PROFILE_PAGE ) { 649 682 /** … … 667 700 do_action( 'edit_user_profile', $profileuser ); 668 701 } 669 ?>670 671 <?php672 /**673 * Filters whether to display additional capabilities for the user.674 *675 * The 'Additional Capabilities' section will only be enabled if676 * the number of the user's capabilities exceeds their number of677 * roles.678 *679 * @since 2.8.0680 *681 * @param bool $enable Whether to display the capabilities. Default true.682 * @param WP_User $profileuser The current WP_User object.683 */684 if ( count( $profileuser->caps ) > count( $profileuser->roles )702 ?> 703 704 <?php 705 /** 706 * Filters whether to display additional capabilities for the user. 707 * 708 * The 'Additional Capabilities' section will only be enabled if 709 * the number of the user's capabilities exceeds their number of 710 * roles. 711 * 712 * @since 2.8.0 713 * 714 * @param bool $enable Whether to display the capabilities. Default true. 715 * @param WP_User $profileuser The current WP_User object. 716 */ 717 if ( count( $profileuser->caps ) > count( $profileuser->roles ) 685 718 && apply_filters( 'additional_capabilities_display', true, $profileuser ) 686 ) : ?> 687 <h2><?php _e( 'Additional Capabilities' ); ?></h2> 719 ) : 720 ?> 721 <h2><?php _e( 'Additional Capabilities' ); ?></h2> 688 722 <table class="form-table"> 689 723 <tr class="user-capabilities-wrap"> … … 692 726 <?php 693 727 $output = ''; 694 foreach ( $profileuser->caps as $cap => $value ) {695 if ( ! $wp_roles->is_role( $cap ) ) {696 if ( '' != $output )697 $output .= ', ';698 $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap );699 }728 foreach ( $profileuser->caps as $cap => $value ) { 729 if ( ! $wp_roles->is_role( $cap ) ) { 730 if ( '' != $output ) { 731 $output .= ', '; 732 } 733 $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap ); 700 734 } 735 } 701 736 echo $output; 702 737 ?> … … 707 742 708 743 <input type="hidden" name="action" value="update" /> 709 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id); ?>" />710 711 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile') : __('Update User') ); ?>744 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" /> 745 746 <?php submit_button( IS_PROFILE_PAGE ? __( 'Update Profile' ) : __( 'Update User' ) ); ?> 712 747 713 748 </form> 714 749 </div> 715 750 <?php 716 break;751 break; 717 752 } 718 753 ?> … … 723 758 </script> 724 759 <?php 725 include( ABSPATH . 'wp-admin/admin-footer.php' );760 include( ABSPATH . 'wp-admin/admin-footer.php' );
Note: See TracChangeset
for help on using the changeset viewer.