get_taxonomy_labels

Advertisement

Summery Summery

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

Syntax Syntax

get_taxonomy_labels( WP_Taxonomy $tax )

Parameters Parameters

$tax

(Required) Taxonomy object.

Return Return

(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).

  • 'name'
    (string) General name for the taxonomy, usually plural. The same as and overridden by $tax->label. Default 'Tags'/'Categories'.
  • 'singular_name'
    (string) Name for one object of this taxonomy. Default 'Tag'/'Category'.
  • 'search_items'
    (string) Default 'Search Tags'/'Search Categories'.
  • 'popular_items'
    (string) This label is only used for non-hierarchical taxonomies. Default 'Popular Tags'.
  • 'all_items'
    (string) Default 'All Tags'/'All Categories'.
  • 'parent_item'
    (string) This label is only used for hierarchical taxonomies. Default 'Parent Category'.
  • 'parent_item_colon'
    (string) The same as parent_item, but with colon : in the end.
  • 'edit_item'
    (string) Default 'Edit Tag'/'Edit Category'.
  • 'view_item'
    (string) Default 'View Tag'/'View Category'.
  • 'update_item'
    (string) Default 'Update Tag'/'Update Category'.
  • 'add_new_item'
    (string) Default 'Add New Tag'/'Add New Category'.
  • 'new_item_name'
    (string) Default 'New Tag Name'/'New Category Name'.
  • 'separate_items_with_commas'
    (string) This label is only used for non-hierarchical taxonomies. Default 'Separate tags with commas', used in the meta box.
  • 'add_or_remove_items'
    (string) This 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_used'
    (string) This label is only used on non-hierarchical taxonomies. Default 'Choose from the most used tags', used in the meta box.
  • 'not_found'
    (string) Default 'No tags found'/'No categories found', used in the meta box and taxonomy list table.
  • 'no_terms'
    (string) Default 'No tags'/'No categories', used in the posts and media list tables.
  • 'items_list_navigation'
    (string) Label for the table pagination hidden heading.
  • 'items_list'
    (string) Label for the table hidden heading.
  • 'most_used'
    (string) Title for the Most Used tab. Default 'Most Used'.
  • 'back_to_items'
    (string) Label displayed after a term has been updated.

Source Source

File: wp-includes/taxonomy.php

 *     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 $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 $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 $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.
 * }
 */
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 = array(
		'name'                       => array( _x( 'Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
		'singular_name'              => array( _x( 'Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
		'search_items'               => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
		'popular_items'              => array( __( 'Popular Tags' ), null ),
		'all_items'                  => array( __( 'All Tags' ), __( 'All Categories' ) ),
		'parent_item'                => array( null, __( 'Parent Category' ) ),
		'parent_item_colon'          => array( null, __( 'Parent Category:' ) ),
		'edit_item'                  => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
		'view_item'                  => array( __( 'View Tag' ), __( 'View Category' ) ),
		'update_item'                => array( __( 'Update Tag' ), __( 'Update Category' ) ),
		'add_new_item'               => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
		'new_item_name'              => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
		'separate_items_with_commas' => array( __( 'Separate tags with commas' ), null ),
		'add_or_remove_items'        => array( __( 'Add or remove tags' ), null ),

Advertisement

Changelog Changelog

Changelog
Version Description
4.9.0 Added the most_used and back_to_items labels.
4.4.0 Added the items_list_navigation and items_list labels.
4.3.0 Added the no_terms label.
3.0.0 Introduced.

Advertisement

Leave a Reply