wp/wp-admin/user-edit.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    24 } elseif ( ! get_userdata( $user_id ) ) {
    24 } elseif ( ! get_userdata( $user_id ) ) {
    25 	wp_die( __( 'Invalid user ID.' ) );
    25 	wp_die( __( 'Invalid user ID.' ) );
    26 }
    26 }
    27 
    27 
    28 wp_enqueue_script( 'user-profile' );
    28 wp_enqueue_script( 'user-profile' );
       
    29 
       
    30 if ( wp_is_application_passwords_available_for_user( $user_id ) ) {
       
    31 	wp_enqueue_script( 'application-passwords' );
       
    32 }
    29 
    33 
    30 if ( IS_PROFILE_PAGE ) {
    34 if ( IS_PROFILE_PAGE ) {
    31 	$title = __( 'Profile' );
    35 	$title = __( 'Profile' );
    32 } else {
    36 } else {
    33 	/* translators: %s: User's display name. */
    37 	/* translators: %s: User's display name. */
   196 	<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
   200 	<p><strong><?php _e( 'Profile updated.' ); ?></strong></p>
   197 	<?php else : ?>
   201 	<?php else : ?>
   198 	<p><strong><?php _e( 'User updated.' ); ?></strong></p>
   202 	<p><strong><?php _e( 'User updated.' ); ?></strong></p>
   199 	<?php endif; ?>
   203 	<?php endif; ?>
   200 			<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
   204 			<?php if ( $wp_http_referer && false === strpos( $wp_http_referer, 'user-new.php' ) && ! IS_PROFILE_PAGE ) : ?>
   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>
   205 	<p><a href="<?php echo esc_url( wp_validate_redirect( esc_url_raw( $wp_http_referer ), self_admin_url( 'users.php' ) ) ); ?>"><?php _e( '&larr; Go to Users' ); ?></a></p>
   202 	<?php endif; ?>
   206 	<?php endif; ?>
   203 </div>
   207 </div>
   204 		<?php endif; ?>
   208 		<?php endif; ?>
   205 		<?php if ( isset( $_GET['error'] ) ) : ?>
   209 		<?php if ( isset( $_GET['error'] ) ) : ?>
   206 <div class="notice notice-error">
   210 <div class="notice notice-error">
   603 			?>
   607 			?>
   604 		</p>
   608 		</p>
   605 	</td>
   609 	</td>
   606 </tr>
   610 </tr>
   607 <?php endif; ?>
   611 <?php endif; ?>
   608 
       
   609 		<?php
   612 		<?php
   610 		/**
   613 		/**
   611 		 * Filters the display of the password fields.
   614 		 * Filters the display of the password fields.
   612 		 *
   615 		 *
   613 		 * @since 1.5.1
   616 		 * @since 1.5.1
   626 <table class="form-table" role="presentation">
   629 <table class="form-table" role="presentation">
   627 <tr id="password" class="user-pass1-wrap">
   630 <tr id="password" class="user-pass1-wrap">
   628 	<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
   631 	<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
   629 	<td>
   632 	<td>
   630 		<input class="hidden" value=" " /><!-- #24364 workaround -->
   633 		<input class="hidden" value=" " /><!-- #24364 workaround -->
   631 		<button type="button" class="button wp-generate-pw hide-if-no-js"><?php _e( 'Generate Password' ); ?></button>
   634 		<button type="button" class="button wp-generate-pw hide-if-no-js" aria-expanded="false"><?php _e( 'Set New Password' ); ?></button>
   632 		<div class="wp-pwd hide-if-js">
   635 		<div class="wp-pwd hide-if-js">
   633 			<span class="password-input-wrapper">
   636 			<span class="password-input-wrapper">
   634 				<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" />
   637 				<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" />
   635 			</span>
   638 			</span>
   636 			<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
   639 			<button type="button" class="button wp-hide-pw hide-if-no-js" data-toggle="0" aria-label="<?php esc_attr_e( 'Hide password' ); ?>">
   646 	</td>
   649 	</td>
   647 </tr>
   650 </tr>
   648 <tr class="user-pass2-wrap hide-if-js">
   651 <tr class="user-pass2-wrap hide-if-js">
   649 	<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
   652 	<th scope="row"><label for="pass2"><?php _e( 'Repeat New Password' ); ?></label></th>
   650 	<td>
   653 	<td>
   651 	<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" />
   654 	<input name="pass2" type="password" id="pass2" class="regular-text" value="" autocomplete="off" aria-describedby="pass2-desc" />
   652 	<p class="description"><?php _e( 'Type your new password again.' ); ?></p>
   655 			<?php if ( IS_PROFILE_PAGE ) : ?>
       
   656 				<p class="description" id="pass2-desc"><?php _e( 'Type your new password again.' ); ?></p>
       
   657 			<?php else : ?>
       
   658 				<p class="description" id="pass2-desc"><?php _e( 'Type the new password again.' ); ?></p>
       
   659 			<?php endif; ?>
   653 	</td>
   660 	</td>
   654 </tr>
   661 </tr>
   655 <tr class="pw-weak">
   662 <tr class="pw-weak">
   656 	<th><?php _e( 'Confirm Password' ); ?></th>
   663 	<th><?php _e( 'Confirm Password' ); ?></th>
   657 	<td>
   664 	<td>
   658 		<label>
   665 		<label>
   659 			<input type="checkbox" name="pw_weak" class="pw-checkbox" />
   666 			<input type="checkbox" name="pw_weak" class="pw-checkbox" />
   660 			<span id="pw-weak-text-label"><?php _e( 'Confirm use of potentially weak password' ); ?></span>
   667 			<span id="pw-weak-text-label"><?php _e( 'Confirm use of weak password' ); ?></span>
   661 		</label>
   668 		</label>
   662 	</td>
   669 	</td>
   663 </tr>
   670 </tr>
   664 	<?php endif; ?>
   671 	<?php endif; ?>
       
   672 
       
   673 		<?php
       
   674 		// Allow admins to send reset password link.
       
   675 		if ( ! IS_PROFILE_PAGE ) :
       
   676 			?>
       
   677 	<tr class="user-generate-reset-link-wrap hide-if-no-js">
       
   678 		<th><?php _e( 'Password Reset' ); ?></th>
       
   679 		<td>
       
   680 			<div class="generate-reset-link">
       
   681 				<button type="button" class="button button-secondary" id="generate-reset-link">
       
   682 					<?php _e( 'Send Reset Link' ); ?>
       
   683 				</button>
       
   684 			</div>
       
   685 			<p class="description">
       
   686 				<?php
       
   687 				/* translators: %s: User's display name. */
       
   688 				printf( __( 'Send %s a link to reset their password. This will not change their password, nor will it force a change.' ), esc_html( $profileuser->display_name ) );
       
   689 				?>
       
   690 			</p>
       
   691 		</td>
       
   692 	</tr>
       
   693 		<?php endif; ?>
   665 
   694 
   666 		<?php
   695 		<?php
   667 		if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) :
   696 		if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) :
   668 			?>
   697 			?>
   669 	<tr class="user-sessions-wrap hide-if-no-js">
   698 	<tr class="user-sessions-wrap hide-if-no-js">
   699 		</td>
   728 		</td>
   700 	</tr>
   729 	</tr>
   701 <?php endif; ?>
   730 <?php endif; ?>
   702 
   731 
   703 	</table>
   732 	</table>
       
   733 
       
   734 
       
   735 		<?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
       
   736 	<div class="application-passwords hide-if-no-js" id="application-passwords-section">
       
   737 		<h2><?php _e( 'Application Passwords' ); ?></h2>
       
   738 		<p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p>
       
   739 			<?php
       
   740 			if ( is_multisite() ) {
       
   741 				$blogs       = get_blogs_of_user( $user_id, true );
       
   742 				$blogs_count = count( $blogs );
       
   743 				if ( $blogs_count > 1 ) {
       
   744 					?>
       
   745 					<p>
       
   746 						<?php
       
   747 						printf(
       
   748 							/* translators: 1: URL to my-sites.php, 2: Number of sites the user has. */
       
   749 							_n(
       
   750 								'Application passwords grant access to <a href="%1$s">the %2$s site in this installation that you have permissions on</a>.',
       
   751 								'Application passwords grant access to <a href="%1$s">all %2$s sites in this installation that you have permissions on</a>.',
       
   752 								$blogs_count
       
   753 							),
       
   754 							admin_url( 'my-sites.php' ),
       
   755 							number_format_i18n( $blogs_count )
       
   756 						);
       
   757 						?>
       
   758 					</p>
       
   759 					<?php
       
   760 				}
       
   761 			}
       
   762 
       
   763 			if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) {
       
   764 				?>
       
   765 			<div class="create-application-password form-wrap">
       
   766 				<div class="form-field">
       
   767 					<label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label>
       
   768 					<input type="text" size="30" id="new_application_password_name" name="new_application_password_name" placeholder="<?php esc_attr_e( 'WordPress App on My Phone' ); ?>" class="input" aria-required="true" aria-describedby="new_application_password_name_desc" />
       
   769 					<p class="description" id="new_application_password_name_desc"><?php _e( 'Required to create an Application Password, but not to update the user.' ); ?></p>
       
   770 				</div>
       
   771 
       
   772 				<?php
       
   773 				/**
       
   774 				 * Fires in the create Application Passwords form.
       
   775 				 *
       
   776 				 * @since 5.6.0
       
   777 				 *
       
   778 				 * @param WP_User $profileuser The current WP_User object.
       
   779 				 */
       
   780 				do_action( 'wp_create_application_password_form', $profileuser );
       
   781 				?>
       
   782 
       
   783 				<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
       
   784 			</div>
       
   785 		<?php } else { ?>
       
   786 			<div class="notice notice-error inline">
       
   787 				<p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
       
   788 			</div>
       
   789 		<?php } ?>
       
   790 
       
   791 		<div class="application-passwords-list-table-wrapper">
       
   792 			<?php
       
   793 			$application_passwords_list_table = _get_list_table( 'WP_Application_Passwords_List_Table', array( 'screen' => 'application-passwords-user' ) );
       
   794 			$application_passwords_list_table->prepare_items();
       
   795 			$application_passwords_list_table->display();
       
   796 			?>
       
   797 		</div>
       
   798 	</div>
       
   799 <?php endif; ?>
   704 
   800 
   705 		<?php
   801 		<?php
   706 		if ( IS_PROFILE_PAGE ) {
   802 		if ( IS_PROFILE_PAGE ) {
   707 			/**
   803 			/**
   708 			 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen.
   804 			 * Fires after the 'About Yourself' settings table on the 'Profile' editing screen.
   785 <script type="text/javascript">
   881 <script type="text/javascript">
   786 	if (window.location.hash == '#password') {
   882 	if (window.location.hash == '#password') {
   787 		document.getElementById('pass1').focus();
   883 		document.getElementById('pass1').focus();
   788 	}
   884 	}
   789 </script>
   885 </script>
       
   886 
       
   887 <?php if ( isset( $application_passwords_list_table ) ) : ?>
       
   888 	<script type="text/html" id="tmpl-new-application-password">
       
   889 		<div class="notice notice-success is-dismissible new-application-password-notice" role="alert" tabindex="-1">
       
   890 			<p class="application-password-display">
       
   891 				<label for="new-application-password-value">
       
   892 					<?php
       
   893 					printf(
       
   894 						/* translators: %s: Application name. */
       
   895 						__( 'Your new password for %s is:' ),
       
   896 						'<strong>{{ data.name }}</strong>'
       
   897 					);
       
   898 					?>
       
   899 				</label>
       
   900 				<input id="new-application-password-value" type="text" class="code" readonly="readonly" value="{{ data.password }}" />
       
   901 			</p>
       
   902 			<p><?php _e( 'Be sure to save this in a safe location. You will not be able to retrieve it.' ); ?></p>
       
   903 			<button type="button" class="notice-dismiss">
       
   904 				<span class="screen-reader-text"><?php _e( 'Dismiss this notice.' ); ?></span>
       
   905 			</button>
       
   906 		</div>
       
   907 	</script>
       
   908 
       
   909 	<script type="text/html" id="tmpl-application-password-row">
       
   910 		<?php $application_passwords_list_table->print_js_template_row(); ?>
       
   911 	</script>
       
   912 <?php endif; ?>
   790 <?php
   913 <?php
   791 require_once ABSPATH . 'wp-admin/admin-footer.php';
   914 require_once ABSPATH . 'wp-admin/admin-footer.php';