WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 5 months ago

#52724 new enhancement

Add filters to term label and info values

Reported by: dingo_d Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: dev-feedback 2nd-opinion has-patch
Focuses: ui Cc:

Description

Inside edit-tags.php and edit-tag-form.php label values for term names and descriptions cannot be changed. They can be translated, but that's it.

I propose to add filters to these so that we can change the names of the labels in a specific taxonomy of our liking.

Something like

<div class="form-field form-required term-name-wrap">
        <label for="tag-name"><?php echo apply_filters( "{$taxonomy}_term_name_label", _x( 'Name', 'term name' ) ); ?></label>
        <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
        <p><?php _e( 'The name is how it appears on your site.' ); ?></p>
</div>

The new filter

<?php
apply_filters( "{$taxonomy}_term_name_label", string $name_label )

would allow developers to change these if they have a specific purpose for taxonomies. For instance, you are building a feature where you need many to many relationships, like books and authors, and books are custom post types, while authors are terms in author taxonomy. Just having a 'Name' is lacking a bit, because you want to put the author's full name (name and surname) as the name of the term.

The same would be for the description and info notices below them. So in total 4 filters:

<?php
apply_filters( "{$taxonomy}_term_name_label", string $name_label )

apply_filters( "{$taxonomy}_term_name_info", string $name_label )

apply_filters( "{$taxonomy}_term_description_label", string $name_label )

apply_filters( "{$taxonomy}_term_description_info", string $name_label )

I'll prepare a patch for this.

Attachments (1)

52724.diff (6.2 KB) - added by dingo_d 7 months ago.
Added new filters for the labels

Download all attachments as: .zip

Change History (2)

@dingo_d
7 months ago

Added new filters for the labels

#1 @laurencebahiirwa
5 months ago

  • Keywords has-patch added; needs-patch removed

I have the same request. I have had several use-cases for this and was lost in docs. Thanks for opening this @dingo_d. I hope it is accepted.

Note: See TracTickets for help on using tickets.