]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/user-edit.php
WordPress 4.7.2
[autoinstalls/wordpress.git] / wp-admin / user-edit.php
1 <?php
2 /**
3  * Edit user administration panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once( dirname( __FILE__ ) . '/admin.php' );
11
12 wp_reset_vars( array( 'action', 'user_id', 'wp_http_referer' ) );
13
14 $user_id = (int) $user_id;
15 $current_user = wp_get_current_user();
16 if ( ! defined( 'IS_PROFILE_PAGE' ) )
17         define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) );
18
19 if ( ! $user_id && IS_PROFILE_PAGE )
20         $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');
27
28 $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
29 if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
30         $submenu_file = 'users.php';
31 else
32         $submenu_file = 'profile.php';
33
34 if ( current_user_can('edit_users') && !is_user_admin() )
35         $parent_file = 'users.php';
36 else
37         $parent_file = 'profile.php';
38
39 $profile_help = '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
40         '<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>' .
41         '<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' .
42         '<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>' .
43         '<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>' .
44         '<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>' .
45         '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
46
47 get_current_screen()->add_help_tab( array(
48         'id'      => 'overview',
49         'title'   => __('Overview'),
50         'content' => $profile_help,
51 ) );
52
53 get_current_screen()->set_help_sidebar(
54     '<p><strong>' . __('For more information:') . '</strong></p>' .
55     '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' .
56     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
57 );
58
59 $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
60
61 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
62
63 /**
64  * Filters whether to allow administrators on Multisite to edit every user.
65  *
66  * Enabling the user editing form via this filter also hinges on the user holding
67  * the 'manage_network_users' cap, and the logged-in user not matching the user
68  * profile open for editing.
69  *
70  * The filter was introduced to replace the EDIT_ANY_USER constant.
71  *
72  * @since 3.0.0
73  *
74  * @param bool $allow Whether to allow editing of any user. Default true.
75  */
76 if ( is_multisite()
77         && ! current_user_can( 'manage_network_users' )
78         && $user_id != $current_user->ID
79         && ! apply_filters( 'enable_edit_any_user_configuration', true )
80 ) {
81         wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
82 }
83
84 // Execute confirmed email change. See send_confirmation_on_profile_email().
85 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
86         $new_email = get_user_meta( $current_user->ID, '_new_email', true );
87         if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) {
88                 $user = new stdClass;
89                 $user->ID = $current_user->ID;
90                 $user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
91                 if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
92                         $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
93                 }
94                 wp_update_user( $user );
95                 delete_user_meta( $current_user->ID, '_new_email' );
96                 wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
97                 die();
98         } else {
99                 wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) );
100         }
101 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
102         check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
103         delete_user_meta( $current_user->ID, '_new_email' );
104         wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
105         die();
106 }
107
108 switch ($action) {
109 case 'update':
110
111 check_admin_referer('update-user_' . $user_id);
112
113 if ( !current_user_can('edit_user', $user_id) )
114         wp_die(__('Sorry, you are not allowed to edit this user.'));
115
116 if ( IS_PROFILE_PAGE ) {
117         /**
118          * Fires before the page loads on the 'Your Profile' editing screen.
119          *
120          * The action only fires if the current user is editing their own profile.
121          *
122          * @since 2.0.0
123          *
124          * @param int $user_id The user ID.
125          */
126         do_action( 'personal_options_update', $user_id );
127 } else {
128         /**
129          * Fires before the page loads on the 'Edit User' screen.
130          *
131          * @since 2.7.0
132          *
133          * @param int $user_id The user ID.
134          */
135         do_action( 'edit_user_profile_update', $user_id );
136 }
137
138 // Update the email address in signups, if present.
139 if ( is_multisite() ) {
140         $user = get_userdata( $user_id );
141
142         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 ) ) ) {
143                 $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $_POST[ 'email' ], $user_login ) );
144         }
145 }
146
147 // Update the user.
148 $errors = edit_user( $user_id );
149
150 // Grant or revoke super admin status if requested.
151 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 ) ) {
152         empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
153 }
154
155 if ( !is_wp_error( $errors ) ) {
156         $redirect = add_query_arg( 'updated', true, get_edit_user_link( $user_id ) );
157         if ( $wp_http_referer )
158                 $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
159         wp_redirect($redirect);
160         exit;
161 }
162
163 default:
164 $profileuser = get_user_to_edit($user_id);
165
166 if ( !current_user_can('edit_user', $user_id) )
167         wp_die(__('Sorry, you are not allowed to edit this user.'));
168
169 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
170
171 include(ABSPATH . 'wp-admin/admin-header.php');
172 ?>
173
174 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
175         <div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
176 <?php } ?>
177 <?php if ( isset($_GET['updated']) ) : ?>
178 <div id="message" class="updated notice is-dismissible">
179         <?php if ( IS_PROFILE_PAGE ) : ?>
180         <p><strong><?php _e('Profile updated.') ?></strong></p>
181         <?php else: ?>
182         <p><strong><?php _e('User updated.') ?></strong></p>
183         <?php endif; ?>
184         <?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
185         <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Users'); ?></a></p>
186         <?php endif; ?>
187 </div>
188 <?php endif; ?>
189 <?php if ( isset( $_GET['error'] ) ) : ?>
190 <div class="notice notice-error">
191         <?php if ( 'new-email' == $_GET['error'] ) : ?>
192         <p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
193         <?php endif; ?>
194 </div>
195 <?php endif; ?>
196 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
197 <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
198 <?php endif; ?>
199
200 <div class="wrap" id="profile-page">
201 <h1>
202 <?php
203 echo esc_html( $title );
204 if ( ! IS_PROFILE_PAGE ) {
205         if ( current_user_can( 'create_users' ) ) { ?>
206                 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
207         <?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
208                 <a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
209         <?php }
210 } ?>
211 </h1>
212 <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
213         /**
214          * Fires inside the your-profile form tag on the user editing screen.
215          *
216          * @since 3.0.0
217          */
218         do_action( 'user_edit_form_tag' );
219 ?>>
220 <?php wp_nonce_field('update-user_' . $user_id) ?>
221 <?php if ( $wp_http_referer ) : ?>
222         <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
223 <?php endif; ?>
224 <p>
225 <input type="hidden" name="from" value="profile" />
226 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
227 </p>
228
229 <h2><?php _e( 'Personal Options' ); ?></h2>
230
231 <table class="form-table">
232 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
233         <tr class="user-rich-editing-wrap">
234                 <th scope="row"><?php _e( 'Visual Editor' ); ?></th>
235                 <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php if ( ! empty( $profileuser->rich_editing ) ) checked( 'false', $profileuser->rich_editing ); ?> /> <?php _e( 'Disable the visual editor when writing' ); ?></label></td>
236         </tr>
237 <?php endif; ?>
238 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
239 <tr class="user-admin-color-wrap">
240 <th scope="row"><?php _e('Admin Color Scheme')?></th>
241 <td><?php
242         /**
243          * Fires in the 'Admin Color Scheme' section of the user editing screen.
244          *
245          * The section is only enabled if a callback is hooked to the action,
246          * and if there is more than one defined color scheme for the admin.
247          *
248          * @since 3.0.0
249          * @since 3.8.1 Added `$user_id` parameter.
250          *
251          * @param int $user_id The user ID.
252          */
253         do_action( 'admin_color_scheme_picker', $user_id );
254 ?></td>
255 </tr>
256 <?php
257 endif; // $_wp_admin_css_colors
258 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
259 <tr class="user-comment-shortcuts-wrap">
260 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
261 <td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( ! empty( $profileuser->comment_shortcuts ) ) 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>
262 </tr>
263 <?php endif; ?>
264 <tr class="show-admin-bar user-admin-bar-front-wrap">
265 <th scope="row"><?php _e( 'Toolbar' ); ?></th>
266 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>
267 <label for="admin_bar_front">
268 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
269 <?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
270 </fieldset>
271 </td>
272 </tr>
273
274 <?php
275 $languages = get_available_languages();
276 if ( $languages ) : ?>
277 <tr class="user-language-wrap">
278         <th scope="row">
279                 <?php /* translators: The user language selection field label */ ?>
280                 <label for="locale"><?php _e( 'Language' ); ?></label>
281         </th>
282         <td>
283                 <?php
284                 $user_locale = $profileuser->locale;
285
286                 if ( 'en_US' === $user_locale ) {
287                         $user_locale = '';
288                 } elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
289                         $user_locale = 'site-default';
290                 }
291
292                 wp_dropdown_languages( array(
293                         'name'                        => 'locale',
294                         'id'                          => 'locale',
295                         'selected'                    => $user_locale,
296                         'languages'                   => $languages,
297                         'show_available_translations' => false,
298                         'show_option_site_default'    => true
299                 ) );
300                 ?>
301         </td>
302 </tr>
303 <?php
304 endif;
305 ?>
306
307 <?php
308 /**
309  * Fires at the end of the 'Personal Options' settings table on the user editing screen.
310  *
311  * @since 2.7.0
312  *
313  * @param WP_User $profileuser The current WP_User object.
314  */
315 do_action( 'personal_options', $profileuser );
316 ?>
317
318 </table>
319 <?php
320         if ( IS_PROFILE_PAGE ) {
321                 /**
322                  * Fires after the 'Personal Options' settings table on the 'Your Profile' editing screen.
323                  *
324                  * The action only fires if the current user is editing their own profile.
325                  *
326                  * @since 2.0.0
327                  *
328                  * @param WP_User $profileuser The current WP_User object.
329                  */
330                 do_action( 'profile_personal_options', $profileuser );
331         }
332 ?>
333
334 <h2><?php _e( 'Name' ); ?></h2>
335
336 <table class="form-table">
337         <tr class="user-user-login-wrap">
338                 <th><label for="user_login"><?php _e('Username'); ?></label></th>
339                 <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>
340         </tr>
341
342 <?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
343 <tr class="user-role-wrap"><th><label for="role"><?php _e('Role') ?></label></th>
344 <td><select name="role" id="role">
345 <?php
346 // Compare user role against currently editable roles
347 $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
348 $user_role  = reset( $user_roles );
349
350 // print the full list of roles with the primary one selected.
351 wp_dropdown_roles($user_role);
352
353 // print the 'no role' option. Make it selected if the user has no role yet.
354 if ( $user_role )
355         echo '<option value="">' . __('&mdash; No role for this site &mdash;') . '</option>';
356 else
357         echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
358 ?>
359 </select></td></tr>
360 <?php endif; //!IS_PROFILE_PAGE
361
362 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
363 <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th>
364 <td>
365 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
366 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
367 <?php else : ?>
368 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
369 <?php endif; ?>
370 </td></tr>
371 <?php } ?>
372
373 <tr class="user-first-name-wrap">
374         <th><label for="first_name"><?php _e('First Name') ?></label></th>
375         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
376 </tr>
377
378 <tr class="user-last-name-wrap">
379         <th><label for="last_name"><?php _e('Last Name') ?></label></th>
380         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
381 </tr>
382
383 <tr class="user-nickname-wrap">
384         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
385         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
386 </tr>
387
388 <tr class="user-display-name-wrap">
389         <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
390         <td>
391                 <select name="display_name" id="display_name">
392                 <?php
393                         $public_display = array();
394                         $public_display['display_nickname']  = $profileuser->nickname;
395                         $public_display['display_username']  = $profileuser->user_login;
396
397                         if ( !empty($profileuser->first_name) )
398                                 $public_display['display_firstname'] = $profileuser->first_name;
399
400                         if ( !empty($profileuser->last_name) )
401                                 $public_display['display_lastname'] = $profileuser->last_name;
402
403                         if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
404                                 $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
405                                 $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
406                         }
407
408                         if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
409                                 $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
410
411                         $public_display = array_map( 'trim', $public_display );
412                         $public_display = array_unique( $public_display );
413
414                         foreach ( $public_display as $id => $item ) {
415                 ?>
416                         <option <?php selected( $profileuser->display_name, $item ); ?>><?php echo $item; ?></option>
417                 <?php
418                         }
419                 ?>
420                 </select>
421         </td>
422 </tr>
423 </table>
424
425 <h2><?php _e( 'Contact Info' ); ?></h2>
426
427 <table class="form-table">
428 <tr class="user-email-wrap">
429         <th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
430         <td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
431         <?php
432         $new_email = get_user_meta( $current_user->ID, '_new_email', true );
433         if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
434         <div class="updated inline">
435         <p><?php
436                 printf(
437                         /* translators: %s: new email */
438                         __( 'There is a pending change of your email to %s.' ),
439                         '<code>' . esc_html( $new_email['newemail'] ) . '</code>'
440                 );
441                 printf(
442                         ' <a href="%1$s">%2$s</a>',
443                         esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
444                         __( 'Cancel' )
445                 );
446         ?></p>
447         </div>
448         <?php endif; ?>
449         </td>
450 </tr>
451
452 <tr class="user-url-wrap">
453         <th><label for="url"><?php _e('Website') ?></label></th>
454         <td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profileuser->user_url ) ?>" class="regular-text code" /></td>
455 </tr>
456
457 <?php
458         foreach ( wp_get_user_contact_methods( $profileuser ) as $name => $desc ) {
459 ?>
460 <tr class="user-<?php echo $name; ?>-wrap">
461         <th><label for="<?php echo $name; ?>">
462                 <?php
463                 /**
464                  * Filters a user contactmethod label.
465                  *
466                  * The dynamic portion of the filter hook, `$name`, refers to
467                  * each of the keys in the contactmethods array.
468                  *
469                  * @since 2.9.0
470                  *
471                  * @param string $desc The translatable label for the contactmethod.
472                  */
473                 echo apply_filters( "user_{$name}_label", $desc );
474                 ?>
475         </label></th>
476         <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
477 </tr>
478 <?php
479         }
480 ?>
481 </table>
482
483 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
484
485 <table class="form-table">
486 <tr class="user-description-wrap">
487         <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
488         <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
489         <p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
490 </tr>
491
492 <?php if ( get_option( 'show_avatars' ) ) : ?>
493 <tr class="user-profile-picture">
494         <th><?php _e( 'Profile Picture' ); ?></th>
495         <td>
496                 <?php echo get_avatar( $user_id ); ?>
497                 <p class="description"><?php
498                         if ( IS_PROFILE_PAGE ) {
499                                 /* translators: %s: Gravatar URL */
500                                 $description = sprintf( __( 'You can change your profile picture on <a href="%s">Gravatar</a>.' ),
501                                         __( 'https://en.gravatar.com/' )
502                                 );
503                         } else {
504                                 $description = '';
505                         }
506
507                         /**
508                          * Filters the user profile picture description displayed under the Gravatar.
509                          *
510                          * @since 4.4.0
511                          * @since 4.7.0 Added the `$profileuser` parameter.
512                          *
513                          * @param string  $description The description that will be printed.
514                          * @param WP_User $profileuser The current WP_User object.
515                          */
516                         echo apply_filters( 'user_profile_picture_description', $description, $profileuser );
517                 ?></p>
518         </td>
519 </tr>
520 <?php endif; ?>
521
522 <?php
523 /**
524  * Filters the display of the password fields.
525  *
526  * @since 1.5.1
527  * @since 2.8.0 Added the `$profileuser` parameter.
528  * @since 4.4.0 Now evaluated only in user-edit.php.
529  *
530  * @param bool    $show        Whether to show the password fields. Default true.
531  * @param WP_User $profileuser User object for the current user to edit.
532  */
533 if ( $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser ) ) :
534 ?>
535 </table>
536
537 <h2><?php _e( 'Account Management' ); ?></h2>
538 <table class="form-table">
539 <tr id="password" class="user-pass1-wrap">
540         <th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
541         <td>
542                 <input class="hidden" value=" " /><!-- #24364 workaround -->
543                 <button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
544                 <div class="wp-pwd hide-if-js">
545                         <span class="password-input-wrapper">
546                                 <input type="password" name="pass1" id="pass1" class="regular-text" value="" autocomplete="off" data-pw="<?php echo esc_attr( wp_generate_password( 24 ) ); ?>" aria-describedby="pass-strength-result" />
547                         </span>
548                         <button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
549                                 <span class="dashicons dashicons-hidden"></span>
550                                 <span class="text"><?php _e( 'Hide' ); ?></span>
551                         </button>
552                         <button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
553                                 <span class="text"><?php _e( 'Cancel' ); ?></span>
554                         </button>
555                         <div style="display:none" id="pass-strength-result" aria-live="polite"></div>
556                 </div>
557         </td>
558 </tr>
559 <tr class="user-pass2-wrap hide-if-js">
560         <th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
561         <td>
562         <input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
563         <p class="description"><?php _e( 'Type your new password again.' ); ?></p>
564         </td>
565 </tr>
566 <tr class="pw-weak">
567         <th><?php _e( 'Confirm Password' ); ?></th>
568         <td>
569                 <label>
570                         <input type="checkbox" name="pw_weak" class="pw-checkbox" />
571                         <span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
572                 </label>
573         </td>
574 </tr>
575 <?php endif; ?>
576
577 <?php
578 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
579         <tr class="user-sessions-wrap hide-if-no-js">
580                 <th><?php _e( 'Sessions' ); ?></th>
581                 <td aria-live="assertive">
582                         <div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
583                         <p class="description">
584                                 <?php _e( 'You are only logged in at this location.' ); ?>
585                         </p>
586                 </td>
587         </tr>
588 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
589         <tr class="user-sessions-wrap hide-if-no-js">
590                 <th><?php _e( 'Sessions' ); ?></th>
591                 <td aria-live="assertive">
592                         <div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
593                         <p class="description">
594                                 <?php _e( 'Did you lose your phone or leave your account logged in at a public computer? You can log out everywhere else, and stay logged in here.' ); ?>
595                         </p>
596                 </td>
597         </tr>
598 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
599         <tr class="user-sessions-wrap hide-if-no-js">
600                 <th><?php _e( 'Sessions' ); ?></th>
601                 <td>
602                         <p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
603                         <p class="description">
604                                 <?php
605                                 /* translators: 1: User's display name. */
606                                 printf( __( 'Log %s out of all locations.' ), $profileuser->display_name );
607                                 ?>
608                         </p>
609                 </td>
610         </tr>
611 <?php endif; ?>
612
613 </table>
614
615 <?php
616         if ( IS_PROFILE_PAGE ) {
617                 /**
618                  * Fires after the 'About Yourself' settings table on the 'Your Profile' editing screen.
619                  *
620                  * The action only fires if the current user is editing their own profile.
621                  *
622                  * @since 2.0.0
623                  *
624                  * @param WP_User $profileuser The current WP_User object.
625                  */
626                 do_action( 'show_user_profile', $profileuser );
627         } else {
628                 /**
629                  * Fires after the 'About the User' settings table on the 'Edit User' screen.
630                  *
631                  * @since 2.0.0
632                  *
633                  * @param WP_User $profileuser The current WP_User object.
634                  */
635                 do_action( 'edit_user_profile', $profileuser );
636         }
637 ?>
638
639 <?php
640 /**
641  * Filters whether to display additional capabilities for the user.
642  *
643  * The 'Additional Capabilities' section will only be enabled if
644  * the number of the user's capabilities exceeds their number of
645  * roles.
646  *
647  * @since 2.8.0
648  *
649  * @param bool    $enable      Whether to display the capabilities. Default true.
650  * @param WP_User $profileuser The current WP_User object.
651  */
652 if ( count( $profileuser->caps ) > count( $profileuser->roles )
653         && apply_filters( 'additional_capabilities_display', true, $profileuser )
654 ) : ?>
655 <h2><?php _e( 'Additional Capabilities' ); ?></h2>
656 <table class="form-table">
657 <tr class="user-capabilities-wrap">
658         <th scope="row"><?php _e( 'Capabilities' ); ?></th>
659         <td>
660 <?php
661         $output = '';
662         foreach ( $profileuser->caps as $cap => $value ) {
663                 if ( ! $wp_roles->is_role( $cap ) ) {
664                         if ( '' != $output )
665                                 $output .= ', ';
666                         $output .= $value ? $cap : sprintf( __( 'Denied: %s' ), $cap );
667                 }
668         }
669         echo $output;
670 ?>
671         </td>
672 </tr>
673 </table>
674 <?php endif; ?>
675
676 <input type="hidden" name="action" value="update" />
677 <input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr($user_id); ?>" />
678
679 <?php submit_button( IS_PROFILE_PAGE ? __('Update Profile') : __('Update User') ); ?>
680
681 </form>
682 </div>
683 <?php
684 break;
685 }
686 ?>
687 <script type="text/javascript">
688         if (window.location.hash == '#password') {
689                 document.getElementById('pass1').focus();
690         }
691 </script>
692 <?php
693 include( ABSPATH . 'wp-admin/admin-footer.php');