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