get_taxonomy_labels( WP_Taxonomy $tax ): object
- Since
- 3.0.0, 4.3.0, 4.4.0, 4.9.0, 5.7.0, 5.8.0, 5.9.0, 6.6.0
- Source
wp-includes/taxonomy.php:707
Compatibility
- WordPress
- since 6.6.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$taxWP_Taxonomy- Taxonomy object.
Return value
object- Taxonomy labels object. The first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories).
$namestringGeneral name for the taxonomy, usually plural. The same as and overridden by$tax->label. Default 'Tags'/'Categories'.$singular_namestringName for one object of this taxonomy. Default 'Tag'/'Category'.$search_itemsstringDefault 'Search Tags'/'Search Categories'.$popular_itemsstringThis label is only used for non-hierarchical taxonomies. Default 'Popular Tags'.$all_itemsstringDefault 'All Tags'/'All Categories'.$parent_itemstringThis label is only used for hierarchical taxonomies. Default 'Parent Category'.$parent_item_colonstringThe same asparent_item, but with colon:in the end.$name_field_descriptionstringDescription for the Name field on Edit Tags screen. Default 'The name is how it appears on your site'.$slug_field_descriptionstringDescription for the Slug field on Edit Tags screen. Default 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens'.$parent_field_descriptionstringDescription for the Parent field on Edit Tags screen. Default 'Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band'.$desc_field_descriptionstringDescription for the Description field on Edit Tags screen. Default 'The description is not prominent by default; however, some themes may show it'.$edit_itemstringDefault 'Edit Tag'/'Edit Category'.$view_itemstringDefault 'View Tag'/'View Category'.$update_itemstringDefault 'Update Tag'/'Update Category'.$add_new_itemstringDefault 'Add Tag'/'Add Category'.$new_item_namestringDefault 'New Tag Name'/'New Category Name'.$template_namestringDefault 'Tag Archives'/'Category Archives'.$separate_items_with_commasstringThis label is only used for non-hierarchical taxonomies. Default 'Separate tags with commas', used in the meta box.$add_or_remove_itemsstringThis label is only used for non-hierarchical taxonomies. Default 'Add or remove tags', used in the meta box when JavaScript is disabled.$choose_from_most_usedstringThis label is only used on non-hierarchical taxonomies. Default 'Choose from the most used tags', used in the meta box.$not_foundstringDefault 'No tags found'/'No categories found', used in the meta box and taxonomy list table.$no_termsstringDefault 'No tags'/'No categories', used in the posts and media list tables.$filter_by_itemstringThis label is only used for hierarchical taxonomies. Default 'Filter by category', used in the posts list table.$items_list_navigationstringLabel for the table pagination hidden heading.$items_liststringLabel for the table hidden heading.$most_usedstringTitle for the Most Used tab. Default 'Most Used'.$back_to_itemsstringLabel displayed after a term has been updated.$item_linkstringUsed in the block editor. Title for a navigation link block variation. Default 'Tag Link'/'Category Link'.$item_link_descriptionstringUsed in the block editor. Description for a navigation link block variation. Default 'A link to a tag'/'A link to a category'.
Performance profile
How much work a call to get_taxonomy_labels() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 40–67
- Plugin surface
- 1 hook
- Called by
- 1
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 67.
Third-party callbacks on 'taxonomy_labels_{$taxonomy}' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_taxonomy_labels() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 40–56 | ::WP_Taxonomy(), _get_custom_object_labels(), apply_filters(), array_merge() |
!isset($value) && isset($labels) | 53–67 | ::WP_Taxonomy(), _get_custom_object_labels(), _x(), sprintf(), apply_filters(), array_merge() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 67 instructions, 40–67 executed per call, 6 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 1
One hook fires while get_taxonomy_labels() runs, in this order:
- apply_filters( taxonomy_labels_{$taxonomy} )filterline 749 (+42 into the body)
Filters the labels of a specific taxonomy.
Uses · 4
- _get_custom_object_labels()Builds an object with custom-something object (post type, taxonomy) labels out of a custom-something object
- _x()Retrieves translated string with gettext context.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- WP_Taxonomy::get_default_labels()Returns the default labels for taxonomies.
Used by · 1
- WP_Taxonomy::set_props()Sets taxonomy properties.
Source code
function get_taxonomy_labels( $tax ) { $tax->labels = (array) $tax->labels; if ( isset( $tax->helps ) && empty( $tax->labels['separate_items_with_commas'] ) ) { $tax->labels['separate_items_with_commas'] = $tax->helps; } if ( isset( $tax->no_tagcloud ) && empty( $tax->labels['not_found'] ) ) { $tax->labels['not_found'] = $tax->no_tagcloud; } $nohier_vs_hier_defaults = WP_Taxonomy::get_default_labels(); $nohier_vs_hier_defaults['menu_name'] = $nohier_vs_hier_defaults['name']; $labels = _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); if ( ! isset( $tax->labels->template_name ) && isset( $labels->singular_name ) ) { /* translators: %s: Taxonomy name. */ $labels->template_name = sprintf( _x( '%s Archives', 'taxonomy template name' ), $labels->singular_name ); } $taxonomy = $tax->name; $default_labels = clone $labels; /** * Filters the labels of a specific taxonomy. * * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug. * * Possible hook names include: * * - `taxonomy_labels_category` * - `taxonomy_labels_post_tag` * * @since 4.4.0 * * @see get_taxonomy_labels() for the full list of taxonomy labels. * * @param object $labels Object with labels for the taxonomy as member variables. */ $labels = apply_filters( "taxonomy_labels_{$taxonomy}", $labels ); // Ensure that the filtered labels contain all required default values. $labels = (object) array_merge( (array) $default_labels, (array) $labels ); return $labels;}Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
template_name label.from the docblockname_field_description, slug_field_description, parent_field_description, and desc_field_description labels.from the docblockitem_link and item_link_description labels.from the docblockfilter_by_item label.from the docblockmost_used and back_to_items labels.from the docblockitems_list_navigation and items_list labels.from the docblockno_terms label.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/taxonomy.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.