wp/wp-admin/user-edit.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    12 /** WordPress Translation Installation API */
    12 /** WordPress Translation Installation API */
    13 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    13 require_once ABSPATH . 'wp-admin/includes/translation-install.php';
    14 
    14 
    15 $action          = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
    15 $action          = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
    16 $user_id         = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
    16 $user_id         = ! empty( $_REQUEST['user_id'] ) ? absint( $_REQUEST['user_id'] ) : 0;
    17 $wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_text_field( $_REQUEST['wp_http_referer'] ) : '';
    17 $wp_http_referer = ! empty( $_REQUEST['wp_http_referer'] ) ? sanitize_url( $_REQUEST['wp_http_referer'] ) : '';
    18 
    18 
    19 $current_user = wp_get_current_user();
    19 $current_user = wp_get_current_user();
    20 
    20 
    21 if ( ! defined( 'IS_PROFILE_PAGE' ) ) {
    21 if ( ! defined( 'IS_PROFILE_PAGE' ) ) {
    22 	define( 'IS_PROFILE_PAGE', ( $user_id === $current_user->ID ) );
    22 	define( 'IS_PROFILE_PAGE', ( $user_id === $current_user->ID ) );
   212 			);
   212 			);
   213 		endif;
   213 		endif;
   214 
   214 
   215 		if ( isset( $_GET['updated'] ) ) :
   215 		if ( isset( $_GET['updated'] ) ) :
   216 			if ( IS_PROFILE_PAGE ) :
   216 			if ( IS_PROFILE_PAGE ) :
   217 				$message = '<strong>' . __( 'Profile updated.' ) . '</strong>';
   217 				$message = '<p><strong>' . __( 'Profile updated.' ) . '</strong></p>';
   218 			else :
   218 			else :
   219 				$message = '<strong>' . __( 'User updated.' ) . '</strong>';
   219 				$message = '<p><strong>' . __( 'User updated.' ) . '</strong></p>';
   220 			endif;
   220 			endif;
   221 			if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
   221 			if ( $wp_http_referer && ! str_contains( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) :
   222 				$message .= '<a href="' . esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ) . '">' . __( '&larr; Go to Users' ) . '</a>';
   222 				$message .= sprintf(
       
   223 					'<p><a href="%1$s">%2$s</a></p>',
       
   224 					esc_url( wp_validate_redirect( sanitize_url( $wp_http_referer ), self_admin_url( 'users.php' ) ) ),
       
   225 					__( '&larr; Go to Users' )
       
   226 				);
   223 			endif;
   227 			endif;
   224 			wp_admin_notice(
   228 			wp_admin_notice(
   225 				$message,
   229 				$message,
   226 				array(
   230 				array(
   227 					'id'                 => 'message',
   231 					'id'                 => 'message',
   228 					'dismissible'        => true,
   232 					'dismissible'        => true,
   229 					'additional_classes' => array( 'updated' ),
   233 					'additional_classes' => array( 'updated' ),
       
   234 					'paragraph_wrap'     => false,
   230 				)
   235 				)
   231 			);
   236 			);
   232 		endif;
   237 		endif;
   233 
   238 
   234 		if ( isset( $_GET['error'] ) ) :
   239 		if ( isset( $_GET['error'] ) ) :
   259 					<?php echo esc_html( $title ); ?>
   264 					<?php echo esc_html( $title ); ?>
   260 			</h1>
   265 			</h1>
   261 
   266 
   262 			<?php if ( ! IS_PROFILE_PAGE ) : ?>
   267 			<?php if ( ! IS_PROFILE_PAGE ) : ?>
   263 				<?php if ( current_user_can( 'create_users' ) ) : ?>
   268 				<?php if ( current_user_can( 'create_users' ) ) : ?>
   264 					<a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add New User' ); ?></a>
   269 					<a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add User' ); ?></a>
   265 				<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
   270 				<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
   266 					<a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add Existing User' ); ?></a>
   271 					<a href="user-new.php" class="page-title-action"><?php echo esc_html__( 'Add Existing User' ); ?></a>
   267 				<?php endif; ?>
   272 				<?php endif; ?>
   268 			<?php endif; ?>
   273 			<?php endif; ?>
   269 
   274 
   289 				</p>
   294 				</p>
   290 
   295 
   291 				<h2><?php _e( 'Personal Options' ); ?></h2>
   296 				<h2><?php _e( 'Personal Options' ); ?></h2>
   292 
   297 
   293 				<table class="form-table" role="presentation">
   298 				<table class="form-table" role="presentation">
   294 					<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
   299 					<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) && 'false' === $profile_user->rich_editing ) : ?>
   295 						<tr class="user-rich-editing-wrap">
   300 						<tr class="user-rich-editing-wrap">
   296 							<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
   301 							<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
   297 							<td>
   302 							<td>
   298 								<label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> />
   303 								<label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked( 'false', $profile_user->rich_editing ); ?> />
   299 									<?php _e( 'Disable the visual editor when writing' ); ?>
   304 									<?php _e( 'Disable the visual editor when writing' ); ?>
   538 
   543 
   539 				<table class="form-table" role="presentation">
   544 				<table class="form-table" role="presentation">
   540 					<tr class="user-email-wrap">
   545 					<tr class="user-email-wrap">
   541 						<th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
   546 						<th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
   542 						<td>
   547 						<td>
   543 							<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
       
   544 							<?php if ( $profile_user->ID === $current_user->ID ) : ?>
   548 							<?php if ( $profile_user->ID === $current_user->ID ) : ?>
       
   549 								<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
   545 								<p class="description" id="email-description">
   550 								<p class="description" id="email-description">
   546 									<?php _e( 'If you change this, an email will be sent at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
   551 									<?php _e( 'If you change this, an email will be sent at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?>
   547 								</p>
   552 								</p>
       
   553 							<?php else : ?>
       
   554 								<input type="email" name="email" id="email" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
   548 							<?php endif; ?>
   555 							<?php endif; ?>
   549 
   556 
   550 							<?php
   557 							<?php
   551 							$new_email = get_user_meta( $current_user->ID, '_new_email', true );
   558 							$new_email = get_user_meta( $current_user->ID, '_new_email', true );
   552 							if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
   559 							if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
   621 									<?php
   628 									<?php
   622 									if ( IS_PROFILE_PAGE ) {
   629 									if ( IS_PROFILE_PAGE ) {
   623 										$description = sprintf(
   630 										$description = sprintf(
   624 											/* translators: %s: Gravatar URL. */
   631 											/* translators: %s: Gravatar URL. */
   625 											__( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
   632 											__( '<a href="%s">You can change your profile picture on Gravatar</a>.' ),
   626 											__( 'https://en.gravatar.com/' )
   633 											/* translators: The localized Gravatar URL. */
       
   634 											__( 'https://gravatar.com/' )
   627 										);
   635 										);
   628 									} else {
   636 									} else {
   629 										$description = '';
   637 										$description = '';
   630 									}
   638 									}
   631 
   639 
   824 										 * @param WP_User $profile_user The current WP_User object.
   832 										 * @param WP_User $profile_user The current WP_User object.
   825 										 */
   833 										 */
   826 										do_action( 'wp_create_application_password_form', $profile_user );
   834 										do_action( 'wp_create_application_password_form', $profile_user );
   827 										?>
   835 										?>
   828 
   836 
   829 										<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
   837 										<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add Application Password' ); ?></button>
   830 									</div>
   838 									</div>
   831 									<?php
   839 									<?php
   832 								else :
   840 								else :
   833 									wp_admin_notice(
   841 									wp_admin_notice(
   834 										__( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
   842 										__( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ),
   851 								<p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
   859 								<p><?php _e( 'The application password feature requires HTTPS, which is not enabled on this site.' ); ?></p>
   852 								<p>
   860 								<p>
   853 									<?php
   861 									<?php
   854 									printf(
   862 									printf(
   855 										/* translators: %s: Documentation URL. */
   863 										/* translators: %s: Documentation URL. */
   856 										__( 'If this is a development website you can <a href="%s" target="_blank">set the environment type accordingly</a> to enable application passwords.' ),
   864 										__( 'If this is a development website, you can <a href="%s">set the environment type accordingly</a> to enable application passwords.' ),
   857 										__( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' )
   865 										__( 'https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type' )
   858 									);
   866 									);
   859 									?>
   867 									?>
   860 								</p>
   868 								</p>
   861 							<?php endif; ?>
   869 							<?php endif; ?>
   976 						'<strong>{{ data.name }}</strong>'
   984 						'<strong>{{ data.name }}</strong>'
   977 					);
   985 					);
   978 					?>
   986 					?>
   979 				</label>
   987 				</label>
   980 				<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" />
   988 				<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" />
       
   989 				<button type="button" class="button copy-button" data-clipboard-text="{{ data.password }}"><?php _e( 'Copy' ); ?></button>
       
   990 				<span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span>
   981 			</p>
   991 			</p>
   982 			<p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
   992 			<p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
   983 			<button type="button" class="notice-dismiss">
   993 			<button type="button" class="notice-dismiss">
   984 				<span class="screen-reader-text">
   994 				<span class="screen-reader-text">
   985 					<?php
   995 					<?php