Make WordPress Core

Changeset 56665


Ignore:
Timestamp:
09/22/2023 07:56:48 PM (5 months ago)
Author:
joedolson
Message:

Administration: Switch order of label/checkbox in WP_List_Table.

Move the label after the checkbox in WP_List_Table instances. Resolve a false positive that will be presented by automated accessibility testing tools. Follow up to [55954].

Props dimitrism, joedolson, sabernhardt, oglekler, marybaum, tobiasbg.
Fixes #58703.

Location:
trunk/src/wp-admin
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/list-tables.css

    r56450 r56665  
    571571}
    572572
    573 .check-column .label-covers-full-cell {
     573.check-column label {
     574    box-sizing: border-box;
    574575    width: 100%;
    575576    height: 100%;
     
    580581}
    581582
    582 .check-column .label-covers-full-cell + input {
     583.check-column input {
    583584    position: relative;
    584585    z-index: 1;
    585586}
    586587
    587 .check-column .label-covers-full-cell:hover + input {
     588.check-column input:where(:not(:disabled)):hover,
     589.check-column:hover input:where(:not(:disabled)) {
    588590    box-shadow: 0 0 0 1px #2271b1;
     591}
     592
     593.check-column label:hover,
     594.check-column input:hover + label {
     595    background: rgba(0, 0, 0, 0.05);
    589596}
    590597
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r56586 r56665  
    897897        if ( $this->user_can ) {
    898898            ?>
    899         <label class="label-covers-full-cell" for="cb-select-<?php echo $comment->comment_ID; ?>">
     899        <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
     900        <label for="cb-select-<?php echo $comment->comment_ID; ?>">
    900901            <span class="screen-reader-text">
    901902            <?php
     
    905906            </span>
    906907        </label>
    907         <input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
    908908            <?php
    909909        }
  • trunk/src/wp-admin/includes/class-wp-links-list-table.php

    r56586 r56665  
    175175
    176176        ?>
    177         <label class="label-covers-full-cell" for="cb-select-<?php echo $link->link_id; ?>">
     177        <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
     178        <label for="cb-select-<?php echo $link->link_id; ?>">
    178179            <span class="screen-reader-text">
    179180            <?php
     
    183184            </span>
    184185        </label>
    185         <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
    186186        <?php
    187187    }
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r56549 r56665  
    14041404        if ( ! empty( $columns['cb'] ) ) {
    14051405            static $cb_counter = 1;
    1406             $columns['cb']     = '<label class="label-covers-full-cell" for="cb-select-all-' . $cb_counter . '">' .
     1406            $columns['cb']     = '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />
     1407            <label for="cb-select-all-' . $cb_counter . '">' .
    14071408                '<span class="screen-reader-text">' .
    14081409                    /* translators: Hidden accessibility text. */
    14091410                    __( 'Select All' ) .
    14101411                '</span>' .
    1411                 '</label>' .
    1412                 '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
     1412                '</label>';
    14131413            ++$cb_counter;
    14141414        }
  • trunk/src/wp-admin/includes/class-wp-media-list-table.php

    r56586 r56665  
    420420        if ( current_user_can( 'edit_post', $post->ID ) ) {
    421421            ?>
    422             <label class="label-covers-full-cell" for="cb-select-<?php echo $post->ID; ?>">
     422            <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
     423            <label for="cb-select-<?php echo $post->ID; ?>">
    423424                <span class="screen-reader-text">
    424425                <?php
     
    428429                </span>
    429430            </label>
    430             <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
    431431            <?php
    432432        }
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r56586 r56665  
    421421            $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    422422            ?>
    423             <label class="label-covers-full-cell" for="blog_<?php echo $blog['blog_id']; ?>">
     423            <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
     424            <label for="blog_<?php echo $blog['blog_id']; ?>">
    424425                <span class="screen-reader-text">
    425426                <?php
     
    429430                </span>
    430431            </label>
    431             <input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]"
    432                 value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
    433432            <?php
    434433        endif;
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r56586 r56665  
    514514        $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
    515515        ?>
    516         <label class="label-covers-full-cell" for="<?php echo $checkbox_id; ?>" >
     516        <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
     517        <label for="<?php echo $checkbox_id; ?>" >
    517518            <span class="screen-reader-text">
    518519            <?php
     
    525526            </span>
    526527        </label>
    527         <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
    528528        <?php
    529529    }
  • trunk/src/wp-admin/includes/class-wp-ms-users-list-table.php

    r56586 r56665  
    236236        }
    237237        ?>
    238         <label class="label-covers-full-cell" for="blog_<?php echo $user->ID; ?>">
     238        <input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
     239        <label for="blog_<?php echo $user->ID; ?>">
    239240            <span class="screen-reader-text">
    240241            <?php
     
    244245            </span>
    245246        </label>
    246         <input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
    247247        <?php
    248248    }
  • trunk/src/wp-admin/includes/class-wp-plugins-list-table.php

    r56599 r56665  
    994994        } else {
    995995            $checkbox = sprintf(
    996                 '<label class="label-covers-full-cell" for="%1$s"><span class="screen-reader-text">%2$s</span></label>' .
    997                 '<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />',
     996                '<input type="checkbox" name="checked[]" value="%1$s" id="%2$s" />' .
     997                '<label for="%2$s"><span class="screen-reader-text">%3$s</span></label>',
     998                esc_attr( $plugin_file ),
    998999                $checkbox_id,
    9991000                /* translators: Hidden accessibility text. %s: Plugin name. */
    1000                 sprintf( __( 'Select %s' ), $plugin_data['Name'] ),
    1001                 esc_attr( $plugin_file )
     1001                sprintf( __( 'Select %s' ), $plugin_data['Name'] )
    10021002            );
    10031003        }
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r56611 r56665  
    10351035        if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
    10361036            ?>
    1037             <label class="label-covers-full-cell" for="cb-select-<?php the_ID(); ?>">
     1037            <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
     1038            <label for="cb-select-<?php the_ID(); ?>">
    10381039                <span class="screen-reader-text">
    10391040                <?php
     
    10431044                </span>
    10441045            </label>
    1045             <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
    10461046            <div class="locked-indicator">
    10471047                <span class="locked-indicator-icon" aria-hidden="true"></span>
  • trunk/src/wp-admin/includes/class-wp-privacy-requests-table.php

    r56549 r56665  
    417417    public function column_cb( $item ) {
    418418        return sprintf(
    419             '<label class="label-covers-full-cell" for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
    420             '<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" /><span class="spinner"></span>',
     419            '<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" />' .
     420            '<label for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label><span class="spinner"></span>',
    421421            esc_attr( $item->ID ),
    422422            /* translators: Hidden accessibility text. %s: Email address. */
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r56631 r56665  
    365365        if ( current_user_can( 'delete_term', $tag->term_id ) ) {
    366366            return sprintf(
    367                 '<label class="label-covers-full-cell" for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>' .
    368                 '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
     367                '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />' .
     368                '<label for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>',
    369369                $tag->term_id,
    370370                /* translators: Hidden accessibility text. %s: Taxonomy term name. */
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r56547 r56665  
    525525            // Set up the checkbox (because the user is editable, otherwise it's empty).
    526526            $checkbox = sprintf(
    527                 '<label class="label-covers-full-cell" for="user_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
    528                 '<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
     527                '<input type="checkbox" name="users[]" id="user_%1$s" class="%2$s" value="%1$s" />' .
     528                '<label for="user_%1$s"><span class="screen-reader-text">%3$s</span></label>',
    529529                $user_object->ID,
     530                $role_classes,
    530531                /* translators: Hidden accessibility text. %s: User login. */
    531                 sprintf( __( 'Select %s' ), $user_object->user_login ),
    532                 $role_classes
     532                sprintf( __( 'Select %s' ), $user_object->user_login )
    533533            );
    534534
  • trunk/src/wp-admin/update-core.php

    r56600 r56665  
    583583        <td class="check-column">
    584584            <?php if ( $compatible_php ) : ?>
    585                 <label for="<?php echo $checkbox_id; ?>" class="label-covers-full-cell">
     585                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
     586                <label for="<?php echo $checkbox_id; ?>">
    586587                    <span class="screen-reader-text">
    587588                    <?php
     
    591592                    </span>
    592593                </label>
    593                 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $plugin_file ); ?>" />
    594594            <?php endif; ?>
    595595        </td>
     
    761761        <td class="check-column">
    762762            <?php if ( $compatible_wp && $compatible_php ) : ?>
    763                 <label for="<?php echo $checkbox_id; ?>" class="label-covers-full-cell">
     763                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
     764                <label for="<?php echo $checkbox_id; ?>">
    764765                    <span class="screen-reader-text">
    765766                    <?php
     
    769770                    </span>
    770771                </label>
    771                 <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
    772772            <?php endif; ?>
    773773        </td>
Note: See TracChangeset for help on using the changeset viewer.