wpseek.com
A WordPress-centric search engine for devs and theme authors



get_taxonomy_labels › WordPress Function

Since3.0.0
Deprecatedn/a
get_taxonomy_labels ( $tax )
Parameters:
  • (WP_Taxonomy) $tax Taxonomy object.
    Required: Yes
Returns:
  • (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). @type string $name General name for the taxonomy, usually plural. The same as and overridden by `$tax->label`. Default 'Tags'/'Categories'. @type string $singular_name Name for one object of this taxonomy. Default 'Tag'/'Category'. @type string $search_items Default 'Search Tags'/'Search Categories'. @type string $popular_items This label is only used for non-hierarchical taxonomies. Default 'Popular Tags'. @type string $all_items Default 'All Tags'/'All Categories'. @type string $parent_item This label is only used for hierarchical taxonomies. Default 'Parent Category'. @type string $parent_item_colon The same as `parent_item`, but with colon `:` in the end. @type string $name_field_description Description for the Name field on Edit Tags screen. Default 'The name is how it appears on your site'. @type string $slug_field_description Description 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'. @type string $parent_field_description Description 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'. @type string $desc_field_description Description for the Description field on Edit Tags screen. Default 'The description is not prominent by default; however, some themes may show it'. @type string $edit_item Default 'Edit Tag'/'Edit Category'. @type string $view_item Default 'View Tag'/'View Category'. @type string $update_item Default 'Update Tag'/'Update Category'. @type string $add_new_item Default 'Add New Tag'/'Add New Category'. @type string $new_item_name Default 'New Tag Name'/'New Category Name'. @type string $template_name Default 'Tag Archives'/'Category Archives'. @type string $separate_items_with_commas This label is only used for non-hierarchical taxonomies. Default 'Separate tags with commas', used in the meta box. @type string $add_or_remove_items This label is only used for non-hierarchical taxonomies. Default 'Add or remove tags', used in the meta box when JavaScript is disabled. @type string $choose_from_most_used This label is only used on non-hierarchical taxonomies. Default 'Choose from the most used tags', used in the meta box. @type string $not_found Default 'No tags found'/'No categories found', used in the meta box and taxonomy list table. @type string $no_terms Default 'No tags'/'No categories', used in the posts and media list tables. @type string $filter_by_item This label is only used for hierarchical taxonomies. Default 'Filter by category', used in the posts list table. @type string $items_list_navigation Label for the table pagination hidden heading. @type string $items_list Label for the table hidden heading. @type string $most_used Title for the Most Used tab. Default 'Most Used'. @type string $back_to_items Label displayed after a term has been updated. @type string $item_link Used in the block editor. Title for a navigation link block variation. Default 'Tag Link'/'Category Link'. @type string $item_link_description Used in the block editor. Description for a navigation link block variation. Default 'A link to a tag'/'A link to a category'. }
Defined at:
Codex:
Change Log:
  • 4.3.0
  • 4.4.0
  • 4.9.0
  • 5.7.0
  • 5.8.0
  • 5.9.0
  • 6.6.0

Builds an object with all taxonomy labels out of a taxonomy object.



Source

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;
}