From de3fbdecc0eca1ec876dfd04bbf642a7f60a57b4 Mon Sep 17 00:00:00 2001 From: Joe Dolson Date: Fri, 19 Aug 2022 23:04:04 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53913 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/edit-tag-form.php | 17 +++++++++-------- src/wp-admin/edit-tags.php | 18 ++++++++++-------- src/wp-includes/category-template.php | 8 +++++++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/edit-tag-form.php b/src/wp-admin/edit-tag-form.php index 7c22cf471d..9b2110398c 100644 --- a/src/wp-admin/edit-tag-form.php +++ b/src/wp-admin/edit-tag-form.php @@ -145,8 +145,8 @@ if ( isset( $tag->name ) ) { - + @@ -167,8 +167,8 @@ if ( isset( $tag->name ) ) { */ $slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : ''; ?> - + @@ -186,6 +186,7 @@ if ( isset( $tag->name ) ) { 'exclude_tree' => $tag->term_id, 'hierarchical' => true, 'show_option_none' => __( 'None' ), + 'aria_describedby' => 'parent-description', ); /** This filter is documented in wp-admin/edit-tags.php */ @@ -193,17 +194,17 @@ if ( isset( $tag->name ) ) { wp_dropdown_categories( $dropdown_args ); ?> -

+

-

labels->parent_field_description; ?>

+

labels->parent_field_description; ?>

- + - -

labels->name_field_description; ?>

+ +

labels->name_field_description; ?>

- -

labels->slug_field_description; ?>

+ +

labels->slug_field_description; ?>

@@ -500,19 +500,21 @@ if ( $can_edit_terms ) { */ $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' ); + $dropdown_args['aria_describedby'] = 'parent-description'; + wp_dropdown_categories( $dropdown_args ); ?> -

+

-

labels->parent_field_description; ?>

+

labels->parent_field_description; ?>

- -

labels->desc_field_description; ?>

+ +

labels->desc_field_description; ?>

-1, 'value_field' => 'term_id', 'required' => false, + 'aria_describedby' => '', ); $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0; @@ -406,8 +410,10 @@ function wp_dropdown_categories( $args = '' ) { $id = $parsed_args['id'] ? esc_attr( $parsed_args['id'] ) : $name; $required = $parsed_args['required'] ? 'required' : ''; + $aria_describedby_attribute = $parsed_args['aria_describedby'] ? ' aria-describedby="' . esc_attr( $parsed_args['aria_describedby'] ) . '"' : ''; + if ( ! $parsed_args['hide_if_empty'] || ! empty( $categories ) ) { - $output = "\n"; } else { $output = ''; }