wp/wp-admin/user-edit.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    23 elseif ( ! get_userdata( $user_id ) )
    23 elseif ( ! get_userdata( $user_id ) )
    24 	wp_die( __('Invalid user ID.') );
    24 	wp_die( __('Invalid user ID.') );
    25 
    25 
    26 wp_enqueue_script('user-profile');
    26 wp_enqueue_script('user-profile');
    27 
    27 
    28 $title = IS_PROFILE_PAGE ? __('Profile') : __('Edit User');
    28 if ( IS_PROFILE_PAGE ) {
       
    29 	$title = __( 'Profile' );
       
    30 } else {
       
    31 	/* translators: %s: user's display name */
       
    32 	$title = __( 'Edit User %s' );
       
    33 }
       
    34 
    29 if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
    35 if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
    30 	$submenu_file = 'users.php';
    36 	$submenu_file = 'users.php';
    31 else
    37 else
    32 	$submenu_file = 'profile.php';
    38 	$submenu_file = 'profile.php';
    33 
    39 
    36 else
    42 else
    37 	$parent_file = 'profile.php';
    43 	$parent_file = 'profile.php';
    38 
    44 
    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>' .
    45 $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>' .
    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 	'<p>' . __( 'You can select the language you wish to use while using the WordPress administration screen without affecting the language site visitors see.' ) . '</p>' .
    41 	'<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>' .
    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>' .
    42 	'<p>' . __( 'You can log out of other devices, such as your phone or a public computer, by clicking the Log Out of All Other Sessions button.' ) . '</p>' .
    49 	'<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>' .
    43 	'<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>' .
    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>' .
    44 	'<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
    51 	'<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
    45 
    52 
    46 get_current_screen()->add_help_tab( array(
    53 get_current_screen()->add_help_tab( array(
    47 	'id'      => 'overview',
    54 	'id'      => 'overview',
    49 	'content' => $profile_help,
    56 	'content' => $profile_help,
    50 ) );
    57 ) );
    51 
    58 
    52 get_current_screen()->set_help_sidebar(
    59 get_current_screen()->set_help_sidebar(
    53     '<p><strong>' . __('For more information:') . '</strong></p>' .
    60     '<p><strong>' . __('For more information:') . '</strong></p>' .
    54     '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' .
    61     '<p>' . __('<a href="https://codex.wordpress.org/Users_Your_Profile_Screen">Documentation on User Profiles</a>') . '</p>' .
    55     '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    62     '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    56 );
    63 );
    57 
    64 
    58 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer );
    65 $wp_http_referer = remove_query_arg( array( 'update', 'delete_count', 'user_id' ), $wp_http_referer );
    59 
    66 
    60 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
    67 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
    61 
    68 
    62 /**
    69 /**
    63  * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
    70  * Filters whether to allow administrators on Multisite to edit every user.
    64  *
       
    65  * @since 2.7.0
       
    66  *
       
    67  * @param object $user User data object
       
    68  */
       
    69 function use_ssl_preference($user) {
       
    70 ?>
       
    71 	<tr class="user-use-ssl-wrap">
       
    72 		<th scope="row"><?php _e('Use https')?></th>
       
    73 		<td><label for="use_ssl"><input name="use_ssl" type="checkbox" id="use_ssl" value="1" <?php checked('1', $user->use_ssl); ?> /> <?php _e('Always use https when visiting the admin'); ?></label></td>
       
    74 	</tr>
       
    75 <?php
       
    76 }
       
    77 
       
    78 /**
       
    79  * Filter whether to allow administrators on Multisite to edit every user.
       
    80  *
    71  *
    81  * Enabling the user editing form via this filter also hinges on the user holding
    72  * Enabling the user editing form via this filter also hinges on the user holding
    82  * the 'manage_network_users' cap, and the logged-in user not matching the user
    73  * the 'manage_network_users' cap, and the logged-in user not matching the user
    83  * profile open for editing.
    74  * profile open for editing.
    84  *
    75  *
    91 if ( is_multisite()
    82 if ( is_multisite()
    92 	&& ! current_user_can( 'manage_network_users' )
    83 	&& ! current_user_can( 'manage_network_users' )
    93 	&& $user_id != $current_user->ID
    84 	&& $user_id != $current_user->ID
    94 	&& ! apply_filters( 'enable_edit_any_user_configuration', true )
    85 	&& ! apply_filters( 'enable_edit_any_user_configuration', true )
    95 ) {
    86 ) {
    96 	wp_die( __( 'You do not have permission to edit this user.' ) );
    87 	wp_die( __( 'Sorry, you are not allowed to edit this user.' ) );
    97 }
    88 }
    98 
    89 
    99 // Execute confirmed email change. See send_confirmation_on_profile_email().
    90 // Execute confirmed email change. See send_confirmation_on_profile_email().
   100 if ( is_multisite() && IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
    91 if ( IS_PROFILE_PAGE && isset( $_GET[ 'newuseremail' ] ) && $current_user->ID ) {
   101 	$new_email = get_option( $current_user->ID . '_new_email' );
    92 	$new_email = get_user_meta( $current_user->ID, '_new_email', true );
   102 	if ( $new_email[ 'hash' ] == $_GET[ 'newuseremail' ] ) {
    93 	if ( $new_email && hash_equals( $new_email[ 'hash' ], $_GET[ 'newuseremail' ] ) ) {
   103 		$user = new stdClass;
    94 		$user = new stdClass;
   104 		$user->ID = $current_user->ID;
    95 		$user->ID = $current_user->ID;
   105 		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
    96 		$user->user_email = esc_html( trim( $new_email[ 'newemail' ] ) );
   106 		if ( $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) )
    97 		if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
   107 			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
    98 			$wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
       
    99 		}
   108 		wp_update_user( $user );
   100 		wp_update_user( $user );
   109 		delete_option( $current_user->ID . '_new_email' );
   101 		delete_user_meta( $current_user->ID, '_new_email' );
   110 		wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
   102 		wp_redirect( add_query_arg( array( 'updated' => 'true' ), self_admin_url( 'profile.php' ) ) );
   111 		die();
   103 		die();
       
   104 	} else {
       
   105 		wp_redirect( add_query_arg( array( 'error' => 'new-email' ), self_admin_url( 'profile.php' ) ) );
   112 	}
   106 	}
   113 } elseif ( is_multisite() && IS_PROFILE_PAGE && !empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' == $_GET['dismiss'] ) {
   107 } elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
   114 	delete_option( $current_user->ID . '_new_email' );
   108 	check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
       
   109 	delete_user_meta( $current_user->ID, '_new_email' );
   115 	wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
   110 	wp_redirect( add_query_arg( array('updated' => 'true'), self_admin_url( 'profile.php' ) ) );
   116 	die();
   111 	die();
   117 }
   112 }
   118 
   113 
   119 switch ($action) {
   114 switch ($action) {
   120 case 'update':
   115 case 'update':
   121 
   116 
   122 check_admin_referer('update-user_' . $user_id);
   117 check_admin_referer('update-user_' . $user_id);
   123 
   118 
   124 if ( !current_user_can('edit_user', $user_id) )
   119 if ( !current_user_can('edit_user', $user_id) )
   125 	wp_die(__('You do not have permission to edit this user.'));
   120 	wp_die(__('Sorry, you are not allowed to edit this user.'));
   126 
   121 
   127 if ( IS_PROFILE_PAGE ) {
   122 if ( IS_PROFILE_PAGE ) {
   128 	/**
   123 	/**
   129 	 * Fires before the page loads on the 'Your Profile' editing screen.
   124 	 * Fires before the page loads on the 'Your Profile' editing screen.
   130 	 *
   125 	 *
   173 
   168 
   174 default:
   169 default:
   175 $profileuser = get_user_to_edit($user_id);
   170 $profileuser = get_user_to_edit($user_id);
   176 
   171 
   177 if ( !current_user_can('edit_user', $user_id) )
   172 if ( !current_user_can('edit_user', $user_id) )
   178 	wp_die(__('You do not have permission to edit this user.'));
   173 	wp_die(__('Sorry, you are not allowed to edit this user.'));
   179 
   174 
       
   175 $title = sprintf( $title, $profileuser->display_name );
   180 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
   176 $sessions = WP_Session_Tokens::get_instance( $profileuser->ID );
   181 
   177 
   182 include(ABSPATH . 'wp-admin/admin-header.php');
   178 include(ABSPATH . 'wp-admin/admin-header.php');
   183 ?>
   179 ?>
   184 
   180 
   185 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
   181 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
   186 	<div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
   182 	<div class="notice notice-info"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div>
   187 <?php } ?>
   183 <?php } ?>
   188 <?php if ( isset($_GET['updated']) ) : ?>
   184 <?php if ( isset($_GET['updated']) ) : ?>
   189 <div id="message" class="updated notice is-dismissible">
   185 <div id="message" class="updated notice is-dismissible">
   190 	<?php if ( IS_PROFILE_PAGE ) : ?>
   186 	<?php if ( IS_PROFILE_PAGE ) : ?>
   191 	<p><strong><?php _e('Profile updated.') ?></strong></p>
   187 	<p><strong><?php _e('Profile updated.') ?></strong></p>
   192 	<?php else: ?>
   188 	<?php else: ?>
   193 	<p><strong><?php _e('User updated.') ?></strong></p>
   189 	<p><strong><?php _e('User updated.') ?></strong></p>
   194 	<?php endif; ?>
   190 	<?php endif; ?>
   195 	<?php if ( $wp_http_referer && !IS_PROFILE_PAGE ) : ?>
   191 	<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
   196 	<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php _e('&larr; Back to Users'); ?></a></p>
   192 	<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e('&larr; Back to Users'); ?></a></p>
   197 	<?php endif; ?>
   193 	<?php endif; ?>
   198 </div>
   194 </div>
   199 <?php endif; ?>
   195 <?php endif; ?>
       
   196 <?php if ( isset( $_GET['error'] ) ) : ?>
       
   197 <div class="notice notice-error">
       
   198 	<?php if ( 'new-email' == $_GET['error'] ) : ?>
       
   199 	<p><?php _e( 'Error while saving the new email address. Please try again.' ); ?></p>
       
   200 	<?php endif; ?>
       
   201 </div>
       
   202 <?php endif; ?>
   200 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
   203 <?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
   201 <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
   204 <div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
   202 <?php endif; ?>
   205 <?php endif; ?>
   203 
   206 
   204 <div class="wrap" id="profile-page">
   207 <div class="wrap" id="profile-page">
   205 <h2>
   208 <h1 class="wp-heading-inline"><?php
   206 <?php
       
   207 echo esc_html( $title );
   209 echo esc_html( $title );
       
   210 ?></h1>
       
   211 
       
   212 <?php
   208 if ( ! IS_PROFILE_PAGE ) {
   213 if ( ! IS_PROFILE_PAGE ) {
   209 	if ( current_user_can( 'create_users' ) ) { ?>
   214 	if ( current_user_can( 'create_users' ) ) { ?>
   210 		<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
   215 		<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
   211 	<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
   216 	<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
   212 		<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
   217 		<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
   213 	<?php }
   218 	<?php }
   214 } ?>
   219 }
   215 </h2>
   220 ?>
       
   221 
       
   222 <hr class="wp-header-end">
       
   223 
   216 <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
   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
   217 	/**
   225 	/**
   218 	 * Fires inside the your-profile form tag on the user editing screen.
   226 	 * Fires inside the your-profile form tag on the user editing screen.
   219 	 *
   227 	 *
   220 	 * @since 3.0.0
   228 	 * @since 3.0.0
   228 <p>
   236 <p>
   229 <input type="hidden" name="from" value="profile" />
   237 <input type="hidden" name="from" value="profile" />
   230 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
   238 <input type="hidden" name="checkuser_id" value="<?php echo get_current_user_id(); ?>" />
   231 </p>
   239 </p>
   232 
   240 
   233 <h3><?php _e('Personal Options'); ?></h3>
   241 <h2><?php _e( 'Personal Options' ); ?></h2>
   234 
   242 
   235 <table class="form-table">
   243 <table class="form-table">
   236 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
   244 <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
   237 	<tr class="user-rich-editing-wrap">
   245 	<tr class="user-rich-editing-wrap">
   238 		<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
   246 		<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
   239 		<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>
   247 		<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>
       
   248 	</tr>
       
   249 <?php endif; ?>
       
   250 <?php
       
   251 $show_syntax_highlighting_preference = (
       
   252 	// For Custom HTML widget and Additional CSS in Customizer.
       
   253 	user_can( $profileuser, 'edit_theme_options' )
       
   254 	||
       
   255 	// Edit plugins.
       
   256 	user_can( $profileuser, 'edit_plugins' )
       
   257 	||
       
   258 	// Edit themes.
       
   259 	user_can( $profileuser, 'edit_themes' )
       
   260 );
       
   261 ?>
       
   262 <?php if ( $show_syntax_highlighting_preference ) : ?>
       
   263 	<tr class="user-syntax-highlighting-wrap">
       
   264 		<th scope="row"><?php _e( 'Syntax Highlighting' ); ?></th>
       
   265 		<td>
       
   266 			<label for="syntax_highlighting"><input name="syntax_highlighting" type="checkbox" id="syntax_highlighting" value="false" <?php if ( ! empty( $profileuser->syntax_highlighting ) ) checked( 'false', $profileuser->syntax_highlighting ); ?> /> <?php _e( 'Disable syntax highlighting when editing code' ); ?></label>
       
   267 		</td>
   240 	</tr>
   268 	</tr>
   241 <?php endif; ?>
   269 <?php endif; ?>
   242 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
   270 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
   243 <tr class="user-admin-color-wrap">
   271 <tr class="user-admin-color-wrap">
   244 <th scope="row"><?php _e('Admin Color Scheme')?></th>
   272 <th scope="row"><?php _e('Admin Color Scheme')?></th>
   272 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
   300 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> />
   273 <?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
   301 <?php _e( 'Show Toolbar when viewing site' ); ?></label><br />
   274 </fieldset>
   302 </fieldset>
   275 </td>
   303 </td>
   276 </tr>
   304 </tr>
       
   305 
       
   306 <?php
       
   307 $languages = get_available_languages();
       
   308 if ( $languages ) : ?>
       
   309 <tr class="user-language-wrap">
       
   310 	<th scope="row">
       
   311 		<?php /* translators: The user language selection field label */ ?>
       
   312 		<label for="locale"><?php _e( 'Language' ); ?></label>
       
   313 	</th>
       
   314 	<td>
       
   315 		<?php
       
   316 		$user_locale = $profileuser->locale;
       
   317 
       
   318 		if ( 'en_US' === $user_locale ) {
       
   319 			$user_locale = '';
       
   320 		} elseif ( '' === $user_locale || ! in_array( $user_locale, $languages, true ) ) {
       
   321 			$user_locale = 'site-default';
       
   322 		}
       
   323 
       
   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 		) );
       
   332 		?>
       
   333 	</td>
       
   334 </tr>
       
   335 <?php
       
   336 endif;
       
   337 ?>
       
   338 
   277 <?php
   339 <?php
   278 /**
   340 /**
   279  * Fires at the end of the 'Personal Options' settings table on the user editing screen.
   341  * Fires at the end of the 'Personal Options' settings table on the user editing screen.
   280  *
   342  *
   281  * @since 2.7.0
   343  * @since 2.7.0
   299 		 */
   361 		 */
   300 		do_action( 'profile_personal_options', $profileuser );
   362 		do_action( 'profile_personal_options', $profileuser );
   301 	}
   363 	}
   302 ?>
   364 ?>
   303 
   365 
   304 <h3><?php _e('Name') ?></h3>
   366 <h2><?php _e( 'Name' ); ?></h2>
   305 
   367 
   306 <table class="form-table">
   368 <table class="form-table">
   307 	<tr class="user-user-login-wrap">
   369 	<tr class="user-user-login-wrap">
   308 		<th><label for="user_login"><?php _e('Username'); ?></label></th>
   370 		<th><label for="user_login"><?php _e('Username'); ?></label></th>
   309 		<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>
   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>
   390 		</select>
   452 		</select>
   391 	</td>
   453 	</td>
   392 </tr>
   454 </tr>
   393 </table>
   455 </table>
   394 
   456 
   395 <h3><?php _e('Contact Info') ?></h3>
   457 <h2><?php _e( 'Contact Info' ); ?></h2>
   396 
   458 
   397 <table class="form-table">
   459 <table class="form-table">
   398 <tr class="user-email-wrap">
   460 <tr class="user-email-wrap">
   399 	<th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
   461 	<th><label for="email"><?php _e('Email'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
   400 	<td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
   462 	<td><input type="email" name="email" id="email" value="<?php echo esc_attr( $profileuser->user_email ) ?>" class="regular-text ltr" />
   401 	<?php
   463 	<?php
   402 	$new_email = get_option( $current_user->ID . '_new_email' );
   464 	$new_email = get_user_meta( $current_user->ID, '_new_email', true );
   403 	if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
   465 	if ( $new_email && $new_email['newemail'] != $current_user->user_email && $profileuser->ID == $current_user->ID ) : ?>
   404 	<div class="updated inline">
   466 	<div class="updated inline">
   405 	<p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
   467 	<p><?php
       
   468 		printf(
       
   469 			/* translators: %s: new email */
       
   470 			__( 'There is a pending change of your email to %s.' ),
       
   471 			'<code>' . esc_html( $new_email['newemail'] ) . '</code>'
       
   472 		);
       
   473 		printf(
       
   474 			' <a href="%1$s">%2$s</a>',
       
   475 			esc_url( wp_nonce_url( self_admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ), 'dismiss-' . $current_user->ID . '_new_email' ) ),
       
   476 			__( 'Cancel' )
       
   477 		);
       
   478 	?></p>
   406 	</div>
   479 	</div>
   407 	<?php endif; ?>
   480 	<?php endif; ?>
   408 	</td>
   481 	</td>
   409 </tr>
   482 </tr>
   410 
   483 
   418 ?>
   491 ?>
   419 <tr class="user-<?php echo $name; ?>-wrap">
   492 <tr class="user-<?php echo $name; ?>-wrap">
   420 	<th><label for="<?php echo $name; ?>">
   493 	<th><label for="<?php echo $name; ?>">
   421 		<?php
   494 		<?php
   422 		/**
   495 		/**
   423 		 * Filter a user contactmethod label.
   496 		 * Filters a user contactmethod label.
   424 		 *
   497 		 *
   425 		 * The dynamic portion of the filter hook, `$name`, refers to
   498 		 * The dynamic portion of the filter hook, `$name`, refers to
   426 		 * each of the keys in the contactmethods array.
   499 		 * each of the keys in the contactmethods array.
   427 		 *
   500 		 *
   428 		 * @since 2.9.0
   501 		 * @since 2.9.0
   437 <?php
   510 <?php
   438 	}
   511 	}
   439 ?>
   512 ?>
   440 </table>
   513 </table>
   441 
   514 
   442 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
   515 <h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
   443 
   516 
   444 <table class="form-table">
   517 <table class="form-table">
   445 <tr class="user-description-wrap">
   518 <tr class="user-description-wrap">
   446 	<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
   519 	<th><label for="description"><?php _e('Biographical Info'); ?></label></th>
   447 	<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
   520 	<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
   448 	<p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
   521 	<p class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p></td>
   449 </tr>
   522 </tr>
   450 
   523 
   451 <?php
   524 <?php if ( get_option( 'show_avatars' ) ) : ?>
   452 /** This filter is documented in wp-admin/user-new.php */
   525 <tr class="user-profile-picture">
   453 $show_password_fields = apply_filters( 'show_password_fields', true, $profileuser );
   526 	<th><?php _e( 'Profile Picture' ); ?></th>
   454 if ( $show_password_fields ) :
   527 	<td>
   455 ?>
   528 		<?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 			}
       
   538 
       
   539 			/**
       
   540 			 * Filters the user profile picture description displayed under the Gravatar.
       
   541 			 *
       
   542 			 * @since 4.4.0
       
   543 			 * @since 4.7.0 Added the `$profileuser` parameter.
       
   544 			 *
       
   545 			 * @param string  $description The description that will be printed.
       
   546 			 * @param WP_User $profileuser The current WP_User object.
       
   547 			 */
       
   548 			echo apply_filters( 'user_profile_picture_description', $description, $profileuser );
       
   549 		?></p>
       
   550 	</td>
       
   551 </tr>
       
   552 <?php endif; ?>
       
   553 
       
   554 <?php
       
   555 /**
       
   556  * Filters the display of the password fields.
       
   557  *
       
   558  * @since 1.5.1
       
   559  * @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>
       
   570 <table class="form-table">
   456 <tr id="password" class="user-pass1-wrap">
   571 <tr id="password" class="user-pass1-wrap">
   457 	<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
   572 	<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
   458 	<td>
   573 	<td>
   459 		<input class="hidden" value=" " /><!-- #24364 workaround -->
   574 		<input class="hidden" value=" " /><!-- #24364 workaround -->
   460 		<input type="password" name="pass1" id="pass1" class="regular-text" size="16" value="" autocomplete="off" />
   575 		<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
   461 		<p class="description"><?php _e( 'If you would like to change the password type a new one. Otherwise leave this blank.' ); ?></p>
   576 		<div class="wp-pwd hide-if-js">
       
   577 			<span class="password-input-wrapper">
       
   578 				<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" />
       
   579 			</span>
       
   580 			<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
       
   581 				<span class="dashicons dashicons-hidden"></span>
       
   582 				<span class="text"><?php _e( 'Hide' ); ?></span>
       
   583 			</button>
       
   584 			<button type="button" class="button wp-cancel-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Cancel password change' ); ?>">
       
   585 				<span class="text"><?php _e( 'Cancel' ); ?></span>
       
   586 			</button>
       
   587 			<div style="display:none" id="pass-strength-result" aria-live="polite"></div>
       
   588 		</div>
   462 	</td>
   589 	</td>
   463 </tr>
   590 </tr>
   464 <tr class="user-pass2-wrap">
   591 <tr class="user-pass2-wrap hide-if-js">
   465 	<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
   592 	<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
   466 	<td>
   593 	<td>
   467 	<input name="pass2" type="password" id="pass2" class="regular-text" size="16" value="" autocomplete="off" />
   594 	<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
   468 	<p class="description"><?php _e( 'Type your new password again.' ); ?></p>
   595 	<p class="description"><?php _e( 'Type your new password again.' ); ?></p>
   469 	<br />
   596 	</td>
   470 	<div id="pass-strength-result"><?php _e( 'Strength indicator' ); ?></div>
   597 </tr>
   471 	<p class="description indicator-hint"><?php echo wp_get_password_hint(); ?></p>
   598 <tr class="pw-weak">
       
   599 	<th><?php _e( 'Confirm Password' ); ?></th>
       
   600 	<td>
       
   601 		<label>
       
   602 			<input type="checkbox" name="pw_weak" class="pw-checkbox" />
       
   603 			<span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
       
   604 		</label>
   472 	</td>
   605 	</td>
   473 </tr>
   606 </tr>
   474 <?php endif; ?>
   607 <?php endif; ?>
   475 
   608 
   476 <?php
   609 <?php
   477 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
   610 if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
   478 	<tr class="user-sessions-wrap hide-if-no-js">
   611 	<tr class="user-sessions-wrap hide-if-no-js">
   479 		<th>&nbsp;</th>
   612 		<th><?php _e( 'Sessions' ); ?></th>
   480 		<td aria-live="assertive">
   613 		<td aria-live="assertive">
   481 			<div class="destroy-sessions"><button type="button" disabled class="button button-secondary"><?php _e( 'Log Out of All Other Sessions' ); ?></button></div>
   614 			<div class="destroy-sessions"><button type="button" disabled class="button"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
   482 			<p class="description">
   615 			<p class="description">
   483 				<?php _e( 'You are only logged in at this location.' ); ?>
   616 				<?php _e( 'You are only logged in at this location.' ); ?>
   484 			</p>
   617 			</p>
   485 		</td>
   618 		</td>
   486 	</tr>
   619 	</tr>
   487 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
   620 <?php elseif ( IS_PROFILE_PAGE && count( $sessions->get_all() ) > 1 ) : ?>
   488 	<tr class="user-sessions-wrap hide-if-no-js">
   621 	<tr class="user-sessions-wrap hide-if-no-js">
   489 		<th>&nbsp;</th>
   622 		<th><?php _e( 'Sessions' ); ?></th>
   490 		<td aria-live="assertive">
   623 		<td aria-live="assertive">
   491 			<div class="destroy-sessions"><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out of All Other Sessions' ); ?></button></div>
   624 			<div class="destroy-sessions"><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere Else' ); ?></button></div>
   492 			<p class="description">
   625 			<p class="description">
   493 				<?php _e( 'Left your account logged in at a public computer? Lost your phone? This will log you out everywhere except your current browser.' ); ?>
   626 				<?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.' ); ?>
   494 			</p>
   627 			</p>
   495 		</td>
   628 		</td>
   496 	</tr>
   629 	</tr>
   497 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
   630 <?php elseif ( ! IS_PROFILE_PAGE && $sessions->get_all() ) : ?>
   498 	<tr class="user-sessions-wrap hide-if-no-js">
   631 	<tr class="user-sessions-wrap hide-if-no-js">
   499 		<th>&nbsp;</th>
   632 		<th><?php _e( 'Sessions' ); ?></th>
   500 		<td>
   633 		<td>
   501 			<p><button type="button" class="button button-secondary" id="destroy-sessions"><?php _e( 'Log Out of All Sessions' ); ?></button></p>
   634 			<p><button type="button" class="button" id="destroy-sessions"><?php _e( 'Log Out Everywhere' ); ?></button></p>
   502 			<p class="description">
   635 			<p class="description">
   503 				<?php
   636 				<?php
   504 				/* translators: 1: User's display name. */
   637 				/* translators: 1: User's display name. */
   505 				printf( __( 'Log %s out of all sessions' ), $profileuser->display_name );
   638 				printf( __( 'Log %s out of all locations.' ), $profileuser->display_name );
   506 				?>
   639 				?>
   507 			</p>
   640 			</p>
   508 		</td>
   641 		</td>
   509 	</tr>
   642 	</tr>
   510 <?php endif; ?>
   643 <?php endif; ?>
   535 	}
   668 	}
   536 ?>
   669 ?>
   537 
   670 
   538 <?php
   671 <?php
   539 /**
   672 /**
   540  * Filter whether to display additional capabilities for the user.
   673  * Filters whether to display additional capabilities for the user.
   541  *
   674  *
   542  * The 'Additional Capabilities' section will only be enabled if
   675  * The 'Additional Capabilities' section will only be enabled if
   543  * the number of the user's capabilities exceeds their number of
   676  * the number of the user's capabilities exceeds their number of
   544  * of roles.
   677  * roles.
   545  *
   678  *
   546  * @since 2.8.0
   679  * @since 2.8.0
   547  *
   680  *
   548  * @param bool    $enable      Whether to display the capabilities. Default true.
   681  * @param bool    $enable      Whether to display the capabilities. Default true.
   549  * @param WP_User $profileuser The current WP_User object.
   682  * @param WP_User $profileuser The current WP_User object.
   550  */
   683  */
   551 if ( count( $profileuser->caps ) > count( $profileuser->roles )
   684 if ( count( $profileuser->caps ) > count( $profileuser->roles )
   552 	&& apply_filters( 'additional_capabilities_display', true, $profileuser )
   685 	&& apply_filters( 'additional_capabilities_display', true, $profileuser )
   553 ) : ?>
   686 ) : ?>
   554 <h3><?php _e( 'Additional Capabilities' ); ?></h3>
   687 <h2><?php _e( 'Additional Capabilities' ); ?></h2>
   555 <table class="form-table">
   688 <table class="form-table">
   556 <tr class="user-capabilities-wrap">
   689 <tr class="user-capabilities-wrap">
   557 	<th scope="row"><?php _e( 'Capabilities' ); ?></th>
   690 	<th scope="row"><?php _e( 'Capabilities' ); ?></th>
   558 	<td>
   691 	<td>
   559 <?php
   692 <?php