Make WordPress Core


Ignore:
Timestamp:
08/19/2022 11:04:04 PM (3 years ago)
Author:
joedolson
Message:

Taxonomy: Associate field descriptions with fields.

Use aria-describedby to associate the field descriptions and instructions with the form fields when creating or editing taxonomy terms.

Props afercia.
Fixes #55651.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-template.php

    r53715 r53913  
    301301 * @since 4.2.0 Introduced the `value_field` argument.
    302302 * @since 4.6.0 Introduced the `required` argument.
     303 * @since 6.1.0 Introduced the `aria_describedby` argument.
    303304 *
    304305 * @param array|string $args {
     
    336337 *     @type Walker       $walker            Walker object to use to build the output. Default empty which results in a
    337338 *                                           Walker_CategoryDropdown instance being used.
     339 *     @type string       $aria_describedby  The 'id' of an element that contains descriptive text for the select.
     340 *                                           Default empty string.
    338341 * }
    339342 * @return string HTML dropdown list of categories.
     
    362365        'value_field'       => 'term_id',
    363366        'required'          => false,
     367        'aria_describedby'  => '',
    364368    );
    365369
     
    407411    $required = $parsed_args['required'] ? 'required' : '';
    408412
     413    $aria_describedby_attribute = $parsed_args['aria_describedby'] ? ' aria-describedby="' . esc_attr( $parsed_args['aria_describedby'] ) . '"' : '';
     414
    409415    if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) {
    410         $output = "<select $required name='$name' id='$id' class='$class' $tab_index_attribute>\n";
     416        $output = "<select $required name='$name' id='$id' class='$class'$tab_index_attribute$aria_describedby_attribute>\n";
    411417    } else {
    412418        $output = '';
Note: See TracChangeset for help on using the changeset viewer.