Skip to content
Permalink
Browse files

Accessibility: Make sure layout tables across the admin are correctly…

… linearized.

Adds `role="presentation"` to the `<table>` elements used for layout purposes.

Ideally, HTML tables should be used for tabular data. When tables are used for layout purposes, it's important to remove any native semantics so that assistive technologies can correctly announce the table content in a linearized fashion.

Props greatislander, afercia.
Merges [45403] to the 5.2 branch.
See #46899.

git-svn-id: https://develop.svn.wordpress.org/branches/5.2@45834 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Aug 19, 2019
1 parent 7fbb5e9 commit 0f96b40556b62a96b4424ab059c43c8526964f2d
@@ -246,7 +246,7 @@ public function admin_page() {

<h3><?php _e( 'Background Image' ); ?></h3>

<table class="form-table">
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><?php _e( 'Preview' ); ?></th>
@@ -340,7 +340,7 @@ public function admin_page() {

<h3><?php _e( 'Display Options' ); ?></h3>
<form method="post">
<table class="form-table">
<table class="form-table" role="presentation">
<tbody>
<?php if ( get_background_image() ) : ?>
<input name="background-preset" type="hidden" value="custom">
@@ -490,7 +490,7 @@ public function step_1() {

<h3><?php _e( 'Header Image' ); ?></h3>

<table class="form-table">
<table class="form-table" role="presentation">
<tbody>

<?php if ( get_custom_header() || display_header_text() ) : ?>
@@ -628,7 +628,7 @@ public function step_1() {

<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ); ?>">
<?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?>
<table class="form-table">
<table class="form-table" role="presentation">
<tbody>
<?php if ( get_uploaded_header_images() ) : ?>
<tr>
@@ -689,7 +689,7 @@ public function step_1() {

<h3><?php _e( 'Header Text' ); ?></h3>

<table class="form-table">
<table class="form-table" role="presentation">
<tbody>
<tr>
<th scope="row"><?php _e( 'Header Text' ); ?></th>
@@ -127,7 +127,7 @@
$tag_name_value = esc_attr( $tag->name );
}
?>
<table class="form-table">
<table class="form-table" role="presentation">
<tr class="form-field form-required term-name-wrap">
<th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" />
@@ -802,7 +802,7 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
*/
function choose_primary_blog() {
?>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<?php /* translators: My sites label */ ?>
<th scope="row"><label for="primary_blog"><?php _e( 'Primary Site' ); ?></label></th>
@@ -914,7 +914,7 @@ function confirm_delete_users( $users ) {
$site_admins = get_super_admins();
$admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>';
?>
<table class="form-table">
<table class="form-table" role="presentation">
<?php
foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) {
if ( $user_id != '' && $user_id != '0' ) {
@@ -223,7 +223,7 @@ function network_step1( $errors = false ) {
<strong><?php _e( 'You cannot change this later.' ); ?></strong></p>
<p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
<?php // @todo: Link to an MS readme? ?>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th><label><input type="radio" name="subdomain_install" value="1"<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
<td>
@@ -272,7 +272,7 @@ function network_step1( $errors = false ) {
);
?>
</p>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
<td>
@@ -289,7 +289,7 @@ function network_step1( $errors = false ) {
<?php endif; ?>

<h3><?php esc_html_e( 'Network Details' ); ?></h3>
<table class="form-table">
<table class="form-table" role="presentation">
<?php if ( 'localhost' == $hostname ) : ?>
<tr>
<th scope="row"><?php esc_html_e( 'Sub-directory Installation' ); ?></th>
@@ -1605,7 +1605,7 @@ function do_settings_sections( $page ) {
if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section['id'] ] ) ) {
continue;
}
echo '<table class="form-table">';
echo '<table class="form-table" role="presentation">';
do_settings_fields( $page, $section['id'] );
echo '</table>';
}
@@ -113,7 +113,7 @@ function display_setup_form( $error = null ) {
<p class="message"><?php echo $error; ?></p>
<?php } ?>
<form id="setup" method="post" action="install.php?step=2" novalidate="novalidate">
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="weblog_title"><?php _e( 'Site Title' ); ?></label></th>
<td><input name="weblog_title" type="text" id="weblog_title" size="25" value="<?php echo esc_attr( $weblog_title ); ?>" /></td>
@@ -148,7 +148,7 @@
<form method="post" action="settings.php" novalidate="novalidate">
<?php wp_nonce_field( 'siteoptions' ); ?>
<h2><?php _e( 'Operational Settings' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="site_name"><?php _e( 'Network Title' ); ?></label></th>
<td>
@@ -188,7 +188,7 @@
</tr>
</table>
<h2><?php _e( 'Registration Settings' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Allow new registrations' ); ?></th>
<?php
@@ -277,7 +277,7 @@

</table>
<h2><?php _e( 'New Site Settings' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">

<tr>
<th scope="row"><label for="welcome_email"><?php _e( 'Welcome Email' ); ?></label></th>
@@ -358,7 +358,7 @@
</tr>
</table>
<h2><?php _e( 'Upload Settings' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Site upload space' ); ?></th>
<td>
@@ -402,7 +402,7 @@
if ( ! empty( $languages ) || ! empty( $translations ) ) {
?>
<h2><?php _e( 'Language Settings' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th><label for="WPLANG"><?php _e( 'Default Language' ); ?></label></th>
<td>
@@ -152,7 +152,7 @@
<form method="post" action="site-info.php?action=update-site">
<?php wp_nonce_field( 'edit-site' ); ?>
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
<table class="form-table">
<table class="form-table" role="presentation">
<?php
// The main site of the network should not be updated on this page.
if ( $is_main_site ) :
@@ -224,7 +224,7 @@
</p>
<form method="post" action="<?php echo network_admin_url( 'site-new.php?action=add-site' ); ?>" novalidate="novalidate">
<?php wp_nonce_field( 'add-blog', '_wpnonce_add-blog' ); ?>
<table class="form-table">
<table class="form-table" role="presentation">
<tr class="form-field form-required">
<th scope="row"><label for="site-address"><?php _e( 'Site Address (URL)' ); ?> <span class="required">*</span></label></th>
<td>
@@ -111,7 +111,7 @@
<form method="post" action="site-settings.php?action=update-site">
<?php wp_nonce_field( 'edit-site' ); ?>
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
<table class="form-table">
<table class="form-table" role="presentation">
<?php
$blog_prefix = $wpdb->get_blog_prefix( $id );
$sql = "SELECT * FROM {$blog_prefix}options
@@ -300,7 +300,7 @@
<h2 id="add-existing-user"><?php _e( 'Add Existing User' ); ?></h2>
<form action="site-users.php?action=adduser" id="adduser" method="post">
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="newuser"><?php _e( 'Username' ); ?></label></th>
<td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td>
@@ -334,7 +334,7 @@
<h2 id="add-new-user"><?php _e( 'Add New User' ); ?></h2>
<form action="<?php echo network_admin_url( 'site-users.php?action=newuser' ); ?>" id="newuser" method="post">
<input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="user_username"><?php _e( 'Username' ); ?></label></th>
<td><input type="text" class="regular-text" name="user[username]" id="user_username" /></td>
@@ -120,7 +120,7 @@
</div>
<?php } ?>
<form action="<?php echo network_admin_url( 'user-new.php?action=add-user' ); ?>" id="adduser" method="post" novalidate="novalidate">
<table class="form-table">
<table class="form-table" role="presentation">
<tr class="form-field form-required">
<th scope="row"><label for="username"><?php _e( 'Username' ); ?></label></th>
<td><input type="text" class="regular-text" name="user[username]" id="username" autocapitalize="none" autocorrect="off" maxlength="60" /></td>
@@ -41,7 +41,7 @@
<form method="post" action="options.php">
<?php settings_fields( 'discussion' ); ?>

<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Default article settings' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Default article settings' ); ?></span></legend>
@@ -218,7 +218,7 @@
}
?>

<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Avatar Display' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Avatar Display' ); ?></span></legend>
@@ -58,7 +58,7 @@
<form method="post" action="options.php" novalidate="novalidate">
<?php settings_fields( 'general' ); ?>

<table class="form-table">
<table class="form-table" role="presentation">

<tr>
<th scope="row"><label for="blogname"><?php _e( 'Site Title' ); ?></label></th>
@@ -51,7 +51,7 @@
<h2 class="title"><?php _e( 'Image sizes' ); ?></h2>
<p><?php _e( 'The sizes listed below determine the maximum dimensions in pixels to use when adding an image to the Media Library.' ); ?></p>

<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Thumbnail size' ); ?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Thumbnail size' ); ?></span></legend>
@@ -98,14 +98,14 @@
if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) :
?>
<h2 class="title"><?php _e( 'Embeds' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<?php do_settings_fields( 'media', 'embeds' ); ?>
</table>
<?php endif; ?>

<?php if ( ! is_multisite() ) : ?>
<h2 class="title"><?php _e( 'Uploading Files' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<?php
// If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty)
if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) :
@@ -300,7 +300,7 @@ class="button button-secondary"
?>
</p>

<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e( 'Category base' ); ?></label></th>
<td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td>
@@ -61,7 +61,7 @@

<?php if ( ! get_pages() ) : ?>
<input name="show_on_front" type="hidden" value="posts" />
<table class="form-table">
<table class="form-table" role="presentation">
<?php
if ( 'posts' != get_option( 'show_on_front' ) ) :
update_option( 'show_on_front', 'posts' );
@@ -72,7 +72,7 @@
update_option( 'show_on_front', 'posts' );
}
?>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><?php _e( 'Your homepage displays' ); ?></th>
<td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Your homepage displays' ); ?></span></legend>
@@ -62,7 +62,7 @@
<form method="post" action="options.php">
<?php settings_fields( 'writing' ); ?>

<table class="form-table">
<table class="form-table" role="presentation">
<?php if ( get_site_option( 'initial_db_version' ) < 32453 ) : ?>
<tr>
<th scope="row"><?php _e( 'Formatting' ); ?></th>
@@ -150,7 +150,7 @@
?>
</p>

<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="mailserver_url"><?php _e( 'Mail Server' ); ?></label></th>
<td><input name="mailserver_url" type="text" id="mailserver_url" value="<?php form_option( 'mailserver_url' ); ?>" class="regular-text code" />
@@ -320,7 +320,7 @@
<?php wp_nonce_field( 'options-options' ); ?>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="option_page" value="options" />
<table class="form-table">
<table class="form-table" role="presentation">
<?php
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
@@ -207,7 +207,7 @@ function setup_config_display_header( $body_classes = array() ) {
<h1 class="screen-reader-text"><?php _e( 'Set up your database connection' ); ?></h1>
<form method="post" action="setup-config.php?step=2">
<p><?php _e( 'Below you should enter your database connection details. If you&#8217;re not sure about these, contact your host.' ); ?></p>
<table class="form-table">
<table class="form-table" role="presentation">
<tr>
<th scope="row"><label for="dbname"><?php _e( 'Database Name' ); ?></label></th>
<td><input name="dbname" id="dbname" type="text" size="25" value="wordpress"<?php echo $autofocus; ?>/></td>
@@ -255,7 +255,7 @@

<h2><?php _e( 'Personal Options' ); ?></h2>

<table class="form-table">
<table class="form-table" role="presentation">
<?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?>
<tr class="user-rich-editing-wrap">
<th scope="row"><?php _e( 'Visual Editor' ); ?></th>
@@ -385,7 +385,7 @@

<h2><?php _e( 'Name' ); ?></h2>

<table class="form-table">
<table class="form-table" role="presentation">
<tr class="user-user-login-wrap">
<th><label for="user_login"><?php _e( 'Username' ); ?></label></th>
<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>
@@ -482,7 +482,7 @@

<h2><?php _e( 'Contact Info' ); ?></h2>

<table class="form-table">
<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( $profileuser->user_email ); ?>" class="regular-text ltr" />
@@ -551,7 +551,7 @@

<h2><?php IS_PROFILE_PAGE ? _e( 'About Yourself' ) : _e( 'About the user' ); ?></h2>

<table class="form-table">
<table class="form-table" role="presentation">
<tr class="user-description-wrap">
<th><label for="description"><?php _e( 'Biographical Info' ); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea>
@@ -607,7 +607,7 @@
</table>

<h2><?php _e( 'Account Management' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr id="password" class="user-pass1-wrap">
<th><label for="pass1"><?php _e( 'New Password' ); ?></label></th>
<td>
@@ -728,7 +728,7 @@
) :
?>
<h2><?php _e( 'Additional Capabilities' ); ?></h2>
<table class="form-table">
<table class="form-table" role="presentation">
<tr class="user-capabilities-wrap">
<th scope="row"><?php _e( 'Capabilities' ); ?></th>
<td>

0 comments on commit 0f96b40

Please sign in to comment.
You can’t perform that action at this time.