Coding Standards: Improve formatting in `/wp-admin/user-edit.php`.

This change improves the formatting of `/wp-admin/user-edit.php` to avoid PHPCS failures when adding new code, which previously required new code to be indented multiple times, breaking alignment of the HTML parts. This change avoids disabling/enabling PHPCS for failing sniffs.

Props costdev, johnregan3, peterwilsoncc.
Fixes #54673.

Built from https://develop.svn.wordpress.org/trunk@52820


git-svn-id: http://core.svn.wordpress.org/trunk@52409 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2022-03-04 11:29:04 +00:00
parent 8db01b9c6b
commit 318205d459
2 changed files with 673 additions and 679 deletions

View File

@ -197,9 +197,10 @@ switch ( $action ) {
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) { ?>
<?php if ( ! IS_PROFILE_PAGE && is_super_admin( $profile_user->ID ) && current_user_can( 'manage_network_options' ) ) : ?>
<div class="notice notice-info"><p><strong><?php _e( 'Important:' ); ?></strong> <?php _e( 'This user has super admin privileges.' ); ?></p></div>
<?php } ?>
<?php endif; ?>
<?php if ( isset( $_GET['updated'] ) ) : ?>
<div id="message" class="updated notice is-dismissible">
<?php if ( IS_PROFILE_PAGE ) : ?>
@ -212,6 +213,7 @@ switch ( $action ) {
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( isset( $_GET['error'] ) ) : ?>
<div class="notice notice-error">
<?php if ( 'new-email' === $_GET['error'] ) : ?>
@ -219,28 +221,25 @@ switch ( $action ) {
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ( isset( $errors ) && is_wp_error( $errors ) ) : ?>
<div class="error"><p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p></div>
<div class="error">
<p><?php echo implode( "</p>\n<p>", $errors->get_error_messages() ); ?></p>
</div>
<?php endif; ?>
<div class="wrap" id="profile-page">
<h1 class="wp-heading-inline">
<?php
echo esc_html( $title );
?>
<?php echo esc_html( $title ); ?>
</h1>
<?php
if ( ! IS_PROFILE_PAGE ) {
if ( current_user_can( 'create_users' ) ) {
?>
<?php if ( ! IS_PROFILE_PAGE ) : ?>
<?php if ( current_user_can( 'create_users' ) ) : ?>
<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
<?php elseif ( is_multisite() && current_user_can( 'promote_users' ) ) : ?>
<a href="user-new.php" class="page-title-action"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
<?php
}
}
?>
<?php endif; ?>
<?php endif; ?>
<hr class="wp-header-end">
@ -276,6 +275,7 @@ switch ( $action ) {
</td>
</tr>
<?php endif; ?>
<?php
$show_syntax_highlighting_preference = (
// For Custom HTML widget and Additional CSS in Customizer.
@ -345,10 +345,8 @@ switch ( $action ) {
</td>
</tr>
<?php
$languages = get_available_languages();
if ( $languages ) :
?>
<?php $languages = get_available_languages(); ?>
<?php if ( $languages ) : ?>
<tr class="user-language-wrap">
<th scope="row">
<?php /* translators: The user language selection field label. */ ?>
@ -377,9 +375,7 @@ switch ( $action ) {
?>
</td>
</tr>
<?php
endif;
?>
<?php endif; ?>
<?php
/**
@ -417,8 +413,10 @@ endif;
</tr>
<?php if ( ! IS_PROFILE_PAGE && ! is_network_admin() && current_user_can( 'promote_user', $profile_user->ID ) ) : ?>
<tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th>
<td><select name="role" id="role">
<tr class="user-role-wrap">
<th><label for="role"><?php _e( 'Role' ); ?></label></th>
<td>
<select name="role" id="role">
<?php
// Compare user role against currently editable roles.
$user_roles = array_intersect( array_values( $profile_user->roles ), array_keys( get_editable_roles() ) );
@ -434,21 +432,23 @@ endif;
echo '<option value="" selected="selected">' . __( '&mdash; No role for this site &mdash;' ) . '</option>';
}
?>
</select></td></tr>
<?php
endif; // End if ! IS_PROFILE_PAGE.
</select>
</td>
</tr>
<?php endif; // End if ! IS_PROFILE_PAGE. ?>
if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) {
?>
<tr class="user-super-admin-wrap"><th><?php _e( 'Super Admin' ); ?></th>
<?php if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) : ?>
<tr class="user-super-admin-wrap">
<th><?php _e( 'Super Admin' ); ?></th>
<td>
<?php if ( 0 !== strcasecmp( $profile_user->user_email, get_site_option( 'admin_email' ) ) || ! is_super_admin( $profile_user->ID ) ) : ?>
<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profile_user->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p>
<?php else : ?>
<p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>
<?php endif; ?>
</td></tr>
<?php } ?>
</td>
</tr>
<?php endif; ?>
<tr class="user-first-name-wrap">
<th><label for="first_name"><?php _e( 'First Name' ); ?></label></th>
@ -466,7 +466,9 @@ endif;
</tr>
<tr class="user-display-name-wrap">
<th><label for="display_name"><?php _e( 'Display name publicly as' ); ?></label></th>
<th>
<label for="display_name"><?php _e( 'Display name publicly as' ); ?></label>
</th>
<td>
<select name="display_name" id="display_name">
<?php
@ -494,12 +496,10 @@ endif;
$public_display = array_map( 'trim', $public_display );
$public_display = array_unique( $public_display );
foreach ( $public_display as $id => $item ) {
?>
<?php foreach ( $public_display as $id => $item ) : ?>
<option <?php selected( $profile_user->display_name, $item ); ?>><?php echo $item; ?></option>
<?php
}
?>
<?php endforeach; ?>
</select>
</td>
</tr>
@ -510,19 +510,16 @@ endif;
<table class="form-table" role="presentation">
<tr class="user-email-wrap">
<th><label for="email"><?php _e( 'Email' ); ?> <span class="description"><?php _e( '(required)' ); ?></span></label></th>
<td><input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
<?php
if ( $profile_user->ID === $current_user->ID ) :
?>
<td>
<input type="email" name="email" id="email" aria-describedby="email-description" value="<?php echo esc_attr( $profile_user->user_email ); ?>" class="regular-text ltr" />
<?php if ( $profile_user->ID === $current_user->ID ) : ?>
<p class="description" id="email-description">
<?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>' ); ?>
</p>
<?php
endif;
<?php endif; ?>
$new_email = get_user_meta( $current_user->ID, '_new_email', true );
if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
?>
<?php $new_email = get_user_meta( $current_user->ID, '_new_email', true ); ?>
<?php if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) : ?>
<div class="updated inline">
<p>
<?php
@ -548,11 +545,10 @@ endif;
<td><input type="url" name="url" id="url" value="<?php echo esc_attr( $profile_user->user_url ); ?>" class="regular-text code" /></td>
</tr>
<?php
foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) {
?>
<?php foreach ( wp_get_user_contact_methods( $profile_user ) as $name => $desc ) : ?>
<tr class="user-<?php echo $name; ?>-wrap">
<th><label for="<?php echo $name; ?>">
<th>
<label for="<?php echo $name; ?>">
<?php
/**
* Filters a user contactmethod label.
@ -566,12 +562,13 @@ endif;
*/
echo apply_filters( "user_{$name}_label", $desc );
?>
</label></th>
<td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" /></td>
</label>
</th>
<td>
<input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profile_user->$name ); ?>" class="regular-text" />
</td>
</tr>
<?php
}
?>
<?php endforeach; ?>
</table>
<h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>
@ -627,11 +624,12 @@ endif;
* @param WP_User $profile_user User object for the current user to edit.
*/
$show_password_fields = apply_filters( 'show_password_fields', true, $profile_user );
if ( $show_password_fields ) :
?>
<?php if ( $show_password_fields ) : ?>
</table>
<h2><?php _e( 'Account Management' ); ?></h2>
<table class="form-table" role="presentation">
<tr id="password" class="user-pass1-wrap">
<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
@ -674,12 +672,10 @@ endif;
</label>
</td>
</tr>
<?php endif; ?>
<?php endif; // End Show Password Fields. ?>
<?php
// Allow admins to send reset password link.
if ( ! IS_PROFILE_PAGE ) :
?>
<?php // Allow admins to send reset password link. ?>
<?php if ( ! IS_PROFILE_PAGE ) : ?>
<tr class="user-generate-reset-link-wrap hide-if-no-js">
<th><?php _e( 'Password Reset' ); ?></th>
<td>
@ -701,9 +697,7 @@ endif;
</tr>
<?php endif; ?>
<?php
if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) :
?>
<?php if ( IS_PROFILE_PAGE && count( $sessions->get_all() ) === 1 ) : ?>
<tr class="user-sessions-wrap hide-if-no-js">
<th><?php _e( 'Sessions' ); ?></th>
<td aria-live="assertive">
@ -737,19 +731,18 @@ endif;
</td>
</tr>
<?php endif; ?>
</table>
<?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : // phpcs:disable Generic.WhiteSpace.ScopeIndent ?>
<?php if ( wp_is_application_passwords_available_for_user( $user_id ) || ! wp_is_application_passwords_supported() ) : ?>
<div class="application-passwords hide-if-no-js" id="application-passwords-section">
<h2><?php _e( 'Application Passwords' ); ?></h2>
<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>
<?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
<?php
if ( is_multisite() ) {
if ( is_multisite() ) :
$blogs = get_blogs_of_user( $user_id, true );
$blogs_count = count( $blogs );
if ( $blogs_count > 1 ) {
if ( $blogs_count > 1 ) :
?>
<p>
<?php
@ -766,11 +759,11 @@ endif;
?>
</p>
<?php
}
}
if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) {
endif;
endif;
?>
<?php if ( ! wp_is_site_protected_by_basic_auth( 'front' ) ) : ?>
<div class="create-application-password form-wrap">
<div class="form-field">
<label for="new_application_password_name"><?php _e( 'New Application Password Name' ); ?></label>
@ -791,11 +784,11 @@ endif;
<button type="button" name="do_new_application_password" id="do_new_application_password" class="button button-secondary"><?php _e( 'Add New Application Password' ); ?></button>
</div>
<?php } else { ?>
<?php else : ?>
<div class="notice notice-error inline">
<p><?php _e( 'Your website appears to use Basic Authentication, which is not currently compatible with Application Passwords.' ); ?></p>
</div>
<?php } ?>
<?php endif; ?>
<div class="application-passwords-list-table-wrapper">
<?php
@ -817,7 +810,7 @@ endif;
</p>
<?php endif; ?>
</div>
<?php endif; // phpcs:enable Generic.WhiteSpace.ScopeIndent ?>
<?php endif; // End Application Passwords. ?>
<?php
if ( IS_PROFILE_PAGE ) {
@ -856,11 +849,12 @@ endif;
* @param bool $enable Whether to display the capabilities. Default true.
* @param WP_User $profile_user The current WP_User object.
*/
if ( count( $profile_user->caps ) > count( $profile_user->roles )
&& apply_filters( 'additional_capabilities_display', true, $profile_user )
) :
$display_additional_caps = apply_filters( 'additional_capabilities_display', true, $profile_user );
?>
<?php if ( count( $profile_user->caps ) > count( $profile_user->roles ) && ( true === $display_additional_caps ) ) : ?>
<h2><?php _e( 'Additional Capabilities' ); ?></h2>
<table class="form-table" role="presentation">
<tr class="user-capabilities-wrap">
<th scope="row"><?php _e( 'Capabilities' ); ?></th>
@ -886,7 +880,7 @@ endif;
</td>
</tr>
</table>
<?php endif; ?>
<?php endif; // End Display Additional Capabilities. ?>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="user_id" id="user_id" value="<?php echo esc_attr( $user_id ); ?>" />

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-52819';
$wp_version = '6.0-alpha-52820';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.