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