Make WordPress Core

Ticket #55651: 55651.diff

File 55651.diff, 8.1 KB (added by afercia, 3 years ago)
  • src/wp-admin/edit-tag-form.php

     
    145145        <table class="form-table" role="presentation">
    146146                <tr class="form-field form-required term-name-wrap">
    147147                        <th scope="row"><label for="name"><?php _ex( 'Name', 'term name' ); ?></label></th>
    148                         <td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" />
    149                         <p class="description"><?php echo $tax->labels->name_field_description; ?></p></td>
     148                        <td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" aria-describedby="name-description" />
     149                        <p class="description" id="name-description"><?php echo $tax->labels->name_field_description; ?></p></td>
    150150                </tr>
    151151<?php if ( ! global_terms_enabled() ) { ?>
    152152                <tr class="form-field term-slug-wrap">
     
    167167                         */
    168168                        $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
    169169                        ?>
    170                         <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
    171                         <p class="description"><?php echo $tax->labels->slug_field_description; ?></p></td>
     170                        <td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" aria-describedby="slug-description" />
     171                        <p class="description" id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p></td>
    172172                </tr>
    173173<?php } ?>
    174174<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
     
    186186                                        'exclude_tree'     => $tag->term_id,
    187187                                        'hierarchical'     => true,
    188188                                        'show_option_none' => __( 'None' ),
     189                                        'aria_describedby' => 'parent-description',
    189190                                );
    190191
    191192                                /** This filter is documented in wp-admin/edit-tags.php */
     
    193194                                wp_dropdown_categories( $dropdown_args );
    194195                                ?>
    195196                                <?php if ( 'category' === $taxonomy ) : ?>
    196                                         <p class="description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
     197                                        <p class="description" id="parent-description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
    197198                                <?php else : ?>
    198                                         <p class="description"><?php echo $tax->labels->parent_field_description; ?></p>
     199                                        <p class="description" id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p>
    199200                                <?php endif; ?>
    200201                        </td>
    201202                </tr>
     
    202203<?php endif; // is_taxonomy_hierarchical() ?>
    203204                <tr class="form-field term-description-wrap">
    204205                        <th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
    205                         <td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
    206                         <p class="description"><?php echo $tax->labels->desc_field_description; ?></p></td>
     206                        <td><textarea name="description" id="description" rows="5" cols="50" class="large-text" aria-describedby="description-description"><?php echo $tag->description; // textarea_escaped ?></textarea>
     207                        <p class="description" id="description-description"><?php echo $tax->labels->desc_field_description; ?></p></td>
    207208                </tr>
    208209                <?php
    209210                // Back compat hooks.
  • src/wp-admin/edit-tags.php

     
    453453
    454454<div class="form-field form-required term-name-wrap">
    455455        <label for="tag-name"><?php _ex( 'Name', 'term name' ); ?></label>
    456         <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
    457         <p><?php echo $tax->labels->name_field_description; ?></p>
     456        <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" aria-describedby="name-description" />
     457        <p id="name-description"><?php echo $tax->labels->name_field_description; ?></p>
    458458</div>
    459459        <?php if ( ! global_terms_enabled() ) : ?>
    460460<div class="form-field term-slug-wrap">
    461461        <label for="tag-slug"><?php _e( 'Slug' ); ?></label>
    462         <input name="slug" id="tag-slug" type="text" value="" size="40" />
    463         <p><?php echo $tax->labels->slug_field_description; ?></p>
     462        <input name="slug" id="tag-slug" type="text" value="" size="40" aria-describedby="slug-description" />
     463        <p id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p>
    464464</div>
    465465<?php endif; // global_terms_enabled() ?>
    466466        <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
     
    500500                 */
    501501                $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' );
    502502
     503                $dropdown_args['aria_describedby'] = 'parent-description';
     504
    503505                wp_dropdown_categories( $dropdown_args );
    504506                ?>
    505507                <?php if ( 'category' === $taxonomy ) : ?>
    506                 <p><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
     508                <p id="parent-description"><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
    507509        <?php else : ?>
    508                 <p><?php echo $tax->labels->parent_field_description; ?></p>
     510                <p id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p>
    509511        <?php endif; ?>
    510512</div>
    511513        <?php endif; // is_taxonomy_hierarchical() ?>
    512514<div class="form-field term-description-wrap">
    513515        <label for="tag-description"><?php _e( 'Description' ); ?></label>
    514         <textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
    515         <p><?php echo $tax->labels->desc_field_description; ?></p>
     516        <textarea name="description" id="tag-description" rows="5" cols="40" aria-describedby="description-description"></textarea>
     517        <p id="description-description"><?php echo $tax->labels->desc_field_description; ?></p>
    516518</div>
    517519
    518520        <?php
  • src/wp-includes/category-template.php

     
    298298 * @since 2.1.0
    299299 * @since 4.2.0 Introduced the `value_field` argument.
    300300 * @since 4.6.0 Introduced the `required` argument.
     301 * @since 6.1.0 Introduced the `aria_describedby` argument.
    301302 *
    302303 * @param array|string $args {
    303304 *     Optional. Array or string of arguments to generate a categories drop-down element. See WP_Term_Query::__construct()
     
    333334 *                                           Default false.
    334335 *     @type Walker       $walker            Walker object to use to build the output. Default empty which results in a
    335336 *                                           Walker_CategoryDropdown instance being used.
     337 *     @type string       $aria_describedby  The 'id' of an element that contains descriptive text for the select.
     338 *                                           Default empty string.
    336339 * }
    337340 * @return string HTML dropdown list of categories.
    338341 */
     
    359362                'option_none_value' => -1,
    360363                'value_field'       => 'term_id',
    361364                'required'          => false,
     365                'aria_describedby'  => '',
    362366        );
    363367
    364368        $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
     
    404408        $id       = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name;
    405409        $required = $parsed_args['required'] ? 'required' : '';
    406410
     411        $aria_describedby_attribute = $parsed_args['aria_describedby'] ? ' aria-describedby="' . esc_attr( $parsed_args['aria_describedby'] ) . '"' : '';
     412
    407413        if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
    408                 $output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";
     414                $output = "<select $required name='$name' id='$id' class='$class'$tab_index_attribute$aria_describedby_attribute>\n";
    409415        } else {
    410416                $output = '';
    411417        }