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.
Built from https://develop.svn.wordpress.org/trunk@53913


git-svn-id: http://core.svn.wordpress.org/trunk@53472 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson
2022-08-19 23:06:09 +00:00
parent 82f3535083
commit 806336ce27
4 changed files with 27 additions and 18 deletions

View File

@@ -145,8 +145,8 @@ if ( isset( $tag->name ) ) {
<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" />
<p class="description"><?php echo $tax->labels->name_field_description; ?></p></td>
<td><input name="name" id="name" type="text" value="<?php echo $tag_name_value; ?>" size="40" aria-required="true" aria-describedby="name-description" />
<p class="description" id="name-description"><?php echo $tax->labels->name_field_description; ?></p></td>
</tr>
<?php if ( ! global_terms_enabled() ) { ?>
<tr class="form-field term-slug-wrap">
@@ -167,8 +167,8 @@ if ( isset( $tag->name ) ) {
*/
$slug = isset( $tag->slug ) ? apply_filters( 'editable_slug', $tag->slug, $tag ) : '';
?>
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" />
<p class="description"><?php echo $tax->labels->slug_field_description; ?></p></td>
<td><input name="slug" id="slug" type="text" value="<?php echo esc_attr( $slug ); ?>" size="40" aria-describedby="slug-description" />
<p class="description" id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p></td>
</tr>
<?php } ?>
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
@@ -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 );
?>
<?php if ( 'category' === $taxonomy ) : ?>
<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>
<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>
<?php else : ?>
<p class="description"><?php echo $tax->labels->parent_field_description; ?></p>
<p class="description" id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p>
<?php endif; ?>
</td>
</tr>
<?php endif; // is_taxonomy_hierarchical() ?>
<tr class="form-field term-description-wrap">
<th scope="row"><label for="description"><?php _e( 'Description' ); ?></label></th>
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text"><?php echo $tag->description; // textarea_escaped ?></textarea>
<p class="description"><?php echo $tax->labels->desc_field_description; ?></p></td>
<td><textarea name="description" id="description" rows="5" cols="50" class="large-text" aria-describedby="description-description"><?php echo $tag->description; // textarea_escaped ?></textarea>
<p class="description" id="description-description"><?php echo $tax->labels->desc_field_description; ?></p></td>
</tr>
<?php
// Back compat hooks.

View File

@@ -453,14 +453,14 @@ if ( $can_edit_terms ) {
<div class="form-field form-required term-name-wrap">
<label for="tag-name"><?php _ex( 'Name', 'term name' ); ?></label>
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
<p><?php echo $tax->labels->name_field_description; ?></p>
<input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" aria-describedby="name-description" />
<p id="name-description"><?php echo $tax->labels->name_field_description; ?></p>
</div>
<?php if ( ! global_terms_enabled() ) : ?>
<div class="form-field term-slug-wrap">
<label for="tag-slug"><?php _e( 'Slug' ); ?></label>
<input name="slug" id="tag-slug" type="text" value="" size="40" />
<p><?php echo $tax->labels->slug_field_description; ?></p>
<input name="slug" id="tag-slug" type="text" value="" size="40" aria-describedby="slug-description" />
<p id="slug-description"><?php echo $tax->labels->slug_field_description; ?></p>
</div>
<?php endif; // global_terms_enabled() ?>
<?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
@@ -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 );
?>
<?php if ( 'category' === $taxonomy ) : ?>
<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>
<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>
<?php else : ?>
<p><?php echo $tax->labels->parent_field_description; ?></p>
<p id="parent-description"><?php echo $tax->labels->parent_field_description; ?></p>
<?php endif; ?>
</div>
<?php endif; // is_taxonomy_hierarchical() ?>
<div class="form-field term-description-wrap">
<label for="tag-description"><?php _e( 'Description' ); ?></label>
<textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
<p><?php echo $tax->labels->desc_field_description; ?></p>
<textarea name="description" id="tag-description" rows="5" cols="40" aria-describedby="description-description"></textarea>
<p id="description-description"><?php echo $tax->labels->desc_field_description; ?></p>
</div>
<?php